mar. 30 septembre 2008, 11h38
Gregory
atoutfox.public.association
Re: [UT] gregory
Voila Olivier, un exemple avec des types generiques
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();
}
}
Gregory
_
Permalink : http://www.atoutfox.org/nntp.asp?ID=0000002546