CSharp examples for Custom Type:Extension Methods
Add extension method to IDictionary
using System;//w ww.java2 s .c o m using System.ComponentModel; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public static class DictionaryExtensions { public static void Add<TKey, TValue>(this IDictionary<TKey, TValue> dictionary,TKey key, TValue value) { dictionary.Add(key, value); } } class MainClass { static void Main() { var dictionary = new ConcurrentDictionary<string, int> { { "x", 10 }, { "y", 20 } }; } }