mercredi 8 juillet 2015

Get minimun value from list

I have a class ABC like this

public class ABC{
public int Id {get;set;}
public int UserCount {get;set;}

Now I add following records to a list of type ABC

List<ABC> lstABC = new List<ABC>();
lstABC.Add(new ABC(){Id=1,UserCount=5});
lstABC.Add(new ABC(){Id=2,UserCount=15});
lstABC.Add(new ABC(){Id=3,UserCount=3});
lstABC.Add(new ABC(){Id=4,UserCount=20});

I've another list of type int

List<int> lstIds = new List<int>();

Now i want to find out the minimum value of UserCount by comparing both the list where Id in lstABC should match the items presesnt in lstIds. I can get the minimum value of UserCount by using loops but is there any another way to get the value in an optimized way by avoiding loops?

Aucun commentaire:

Enregistrer un commentaire