>public static class ExtensionMethods >{ > public static bool InList<T>(this T s, params T[] list) > { > return list.Contains(s); > } >} > >class Test >{ > static void Main(string[] args) > { > string s = "456"; > Console.WriteLine(" string {0}", "456".InList("123", "456")); > Console.WriteLine(" string {0}", s.InList("123", "456")); > > int i = 4; > Console.WriteLine(" int {0}", 5.InList(4, 5, 6)); > Console.WriteLine(" int {0}", 29.InList(4, 5, 6)); > Console.WriteLine(" int {0}", i.InList(4,5,6)); > Console.ReadLine(); > > } > >} >