Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP inlist() in c#
Message
From
01/10/2008 16:32:36
 
 
To
30/09/2008 05:36:26
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01320903
Message ID:
01352114
Views:
60
Cool.
I can't actually remember what we were trying to do but I like the way you did it !

But I guess that since extension methods are, under the hood, built as regular methods then generics should work in the same way.

Best,
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();
>
>	}
>
>}
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform