McKelt.com

Remembering Thoughts

 

Recent comments

Authors

Categories


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Extensions Methods

http://vstestingextensions.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22657
public static partial class ExtensionMethods 
    {
        public static IEnumerable<T> Each<T>(this IEnumerable<T> source, Action<T> action)
        {
            if (source != null)
            {
                foreach (T item in source)
                {
                    action(item);
                }                
            }
            return source;
        }

        public static IEnumerable<T> Map<T>(this IEnumerable<T> source, Func<T, T> action)
        {
            foreach (T item in source)
            {
                yield return action(item);
            }
        }

        public static IEnumerable<T> GetDuplicates<T>(this IEnumerable<T> source)
        {
            return
                from item in source
                group item by item
                into g
                    where g.Count() > 1
                    select g.Key;
        }
    }

Posted by chris on Wednesday, July 08, 2009 10:04 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading