Explanation of IEnumerable

Malik

New Member
Down Below I took part of a code I was looking at. I don't understand the IEnumerable part of the Code. Can someone just walk me through the meaning of each line. ThanksI don't understand the Where(u =>) more than the rest.\[code\] public static List<AAlexUsers.Models.SearchClass> Users(string userId, string email, string lastFourdigits) { SearchClass Alex = new SearchClass(); Alex.userId = "1234"; Alex.email = "[email protected]"; Alex.lastFourdigits = "1885"; SearchClass Emilio = new SearchClass(); Emilio.userId = "0928"; Emilio.email = "[email protected]"; Emilio.lastFourdigits = "0706"; SearchClass Ulysses = new SearchClass(); Ulysses.userId = "0914"; Ulysses.email = "[email protected]"; Ulysses.lastFourdigits = "01zx"; var list = new List<SearchClass>(); list.Add(Alex); list.Add(Emilio); list.Add(Ulysses); IEnumerable<SearchClass> result = list; if (!string.IsNullOrEmpty(userId)) result = result.Where(u => u.userId == userId); if (!string.IsNullOrEmpty(email)) result = result.Where(u => u.email == email); if (!string.IsNullOrEmpty(lastFourdigits)) result = result.Where(u => u.lastFourdigits == lastFourdigits); return list.ToList(); }\[/code\]
 
Back
Top