public static class EnumberableExtensions
{ public static IEnumerable<string> IfMatchWith(this IEnumerable<string> myList, string itemToMatch) { foreach (var item in myList.Where(item => item == itemToMatch)) yield return item; } public static IEnumerable<string> IfNotMatchWith(this IEnumerable<string> myList, string itemToMatch) { foreach (var item in myList.Where(item => item != itemToMatch)) yield return item; } public static IEnumerable<string> IgnoreNullOrEmptyOrSpace(this IEnumerable<string> myList) { foreach (var item in myList.Where(item => !string.IsNullOrEmpty(item) && item != " ")) yield return item; } public static IEnumerable<string> MakeAllUpper(this IEnumerable<string> myList) { foreach (var item in myList) yield return item.ToUpper(); } public static IEnumerable<string> MakeAllLower(this IEnumerable<string> myList) { foreach (var item in myList) yield return item.ToLower(); } public static IEnumerable<T> MakeAllDefault<T>(this IEnumerable<T> myList) { foreach (var item in myList) yield return default(T); } public static IEnumerable<string> IfMatchWithPattern(this IEnumerable<string> myList, string pattern) { foreach (var item in myList.Where(item => Regex.IsMatch(item, pattern))) yield return item; } public static IEnumerable<string> IfLengthEquals(this IEnumerable<string> myList, int itemLength) { foreach (var item in myList.Where(item => item.Length == itemLength)) yield return item; } public static IEnumerable<string> IfLengthInRange(this IEnumerable<string> myList, int startOfRange, int endOfRange) { foreach (var item in myList.Where(item => item.Length >= startOfRange && item.Length <= endOfRange)) yield return item; } }
Few extension methods of IEnumerable
Following code shows few extension methods of IEnumerable<string>,
Codeproject article about Template method pattern in C#
I posted another article about Template method pattern and Action in C# in the Codeproject. It could be found in here.
Codeplex - .NET Utility Library project
I just published a project in Codeplex. The project name is DotNetUtility - a .NET Utility Library for C#. The project URL is DotNetUtility - a .NET Utility Library for C#. This is open source and if any one willing to contribute please let me know.
Code project - Caching uses with Proxy pattern in C#
I posted another article about improvement of Proxy Pattern by using Caching technique in C#. It could be found in Caching uses with Proxy pattern in C#.
Subscribe to:
Posts (Atom)