Monday, January 30, 2012

Best Extension Methods: AddRange To Collection

Using below extension method we can add a multiple values to a typed collection in one go.
 //add value to collection in one statement
    public static void AddRange(this ICollection list, params S[] values)
    where S : T
    {
        foreach (S value in values)
            list.Add(value);
    }

Compiled By: Rajesh Rolen

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates