Created
February 27, 2010 01:43
-
-
Save rbazinet/316393 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ListExtensions { | |
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> collection, Action<T> action) { | |
foreach (var item in collection) action(item); | |
return collection; | |
} | |
public static SelectList ToSelectList<T>(this IEnumerable<T> collection) { | |
return new SelectList(collection, "Key", "Value"); | |
} | |
public static SelectList ToSelectList<T>(this IEnumerable<T> collection, string selectedValue) { | |
return new SelectList(collection, "Key", "Value", selectedValue); | |
} | |
public static SelectList ToSelectList<T>(this IEnumerable<T> collection, | |
string dataValueField, string dataTextField) { | |
return new SelectList(collection, dataValueField, dataTextField); | |
} | |
public static SelectList ToSelectList<T>(this IEnumerable<T> collection, | |
string dataValueField, string dataTextField, string selectedValue) { | |
return new SelectList(collection, dataValueField, dataTextField, selectedValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment