Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP inlist() in c#
Message
De
01/10/2008 17:28:08
 
 
À
30/09/2008 05:36:26
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01320903
Message ID:
01352137
Vues:
49
Very cool Gregory ... when I first heard about Extension methods, I got all excited by the idea! I haven't had the time to dig into it yet, but someone told me that they are a bit slow.

Has anyone had any "real-life" experience using Extention methods who can say whether there's a performance issue with them or not?

~~Bonnie




>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();
>
>	}
>
>}
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform