Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP inlist() in c#
Message
From
01/10/2008 17:28:08
 
 
To
30/09/2008 05:36:26
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01320903
Message ID:
01352137
Views:
45
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform