CSharp examples for Custom Type:Extension Methods
Add Extension Methods to Interfaces
using System;/*from ww w .j ava 2 s.co m*/ using System.Collections.Generic; public static class IEnumerableHelper { public static T First<T>(this IEnumerable<T> sequence) { foreach (T element in sequence) return element; throw new InvalidOperationException("No elements!"); } } class Test { static void Main() { Console.WriteLine("Seattle".First()); // S } }