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

Reactions:

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Web Hosting Bluehost