Match elements between 2 collections with Linq in c# -


I have a question about how to do general programming work in linq.

We say that we have different collections or arrays, what do I want to do, match elements between arrays and if anything happens then do something with that element.

Example:

  string [] collection1 = new string [] {"1", "7", "4"}; String [] collection2 = new string [] {"6", "1", "7"}; Foreach (straight 1 in collection 1) {foreach (straight 2 in collection2) {if (str1 == str2) {// do SOTH EXCITING} The form may have been completed using the above code, but am I thinking that if you can do this with LinqtoObjects in a fast and systematic way?  

Thank you!

Yes, intersection - code sample to describe.

  string [collection1 = new string] ["1", "7", "4"}; String [] collection2 = new string [] {"6", "1", "7"}; Var ResultsSat = Collection 1. Intrigue & lt; String & gt; (Collection 2); Foreach (resulting string Asset) {Console.WriteLine (S); }  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -