Tag Archives: Extension Methods

Using the ForEach method on List Collections

public static StateCollection GetByName(String partialName) { StateCollection returnValue; returnValue = new StateCollection(); //baseList is some list I wasn’t nice enough to show where it came from. //It’s just a list of states. Get over it. var stateList = from state in baseList where state.Name.StartsWith(partialName) select new State(state.Name, state.Code); stateList.ToList().ForEach(currentState => returnValue.Add(currentState)); return returnValue; } So [...]

Leave a comment Continue Reading →

IEnumerable Extention Methods and Action

This may be slightly off, but I’ve pretty much figured them out and how they work with lambda expressions. First off, Lambda expressions. These are the odd looking currentItem => expressions you might see in my examples. They are a little misleading, at least to me they were. When I saw: ilist.SomeExtension(currentItem => SomeMethod(currentItem)); I [...]

Leave a comment Continue Reading →