Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP inlist() in c#
Message
De
30/09/2008 05:36:26
 
 
À
02/06/2008 09:02:42
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01320903
Message ID:
01351722
Vues:
230
J'aime (1)
Viv,


It's a bit late - I know - but I came across Extension methods yesterday - and generics work
http://msdn.microsoft.com/en-us/library/bb383977.aspx
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform