c# - How can I get data from a list with a where clause to another list? -


I have a list with many squares which contains the property that is an id.

I also have a list of integers.

Now, I would like to trim the list of my objects only in those categories which are in the list of integers. / P>

Example:

  List of MyObjectA [MyObjectA]. Id = 1 [MyObjectB] .Id = 2 [MyObjectC] .Id = 3 [MyObjectD] should be the last list of IID = 4 list integer 1 2 [MyObjectA] [MyObjectB]  

I How can i do this

You can use it:

  var finalList = originalList .Where (X => idList.Contains (x.Id)). ToList ();  

Or join one:

  var finalList = (Enter entry into IDIILI from the entry in the original entry. ID number is equal to the entry selected) .list ();  

Comments