Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Naming conventions for custom methods?
Message
From
18/11/2008 09:47:59
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01362229
Message ID:
01362532
Views:
29
>>> A method belongs to one and only one class, doesn't it?
>>>
>>
>>Except, perhaps, when your are dealing with extension methods
>>
>>Here's one that applies to all classes
>>
>>
>>public static partial class ExtensionMethods
>>{
>>        static public string MyToString<T>(this T s)
>>	{
>>		return "<" + s.ToString() + ">";
>>	}
>>		
>>}
>>
>>
>>or
>>
>>public static partial class ExtensionMethods
>>{
>>        static public string MyToString(this object s)
>>	{
>>		return "<" + s.ToString() + ">";
>>	}
>>		
>>}
>>
>>
>>
>>Here's one that applies to all classes which implement IEquatable< T >
>>
>>
>>public static partial class ExtensionMethods
>>{
>>     public static bool InList<T>(this T s, params T[] list) where T : IEquatable<T>
>>		{
>>			return list.Contains(s);
>>		}		
>>}
>>
>
>Thanks. Extension methods are still over my head at this point. I kinda sorta understand generics and interfaces, but have not gotten to extension methods. Yet ;-)

hey - I just wanted to point it out - and the first and third use generics

Seriously, I am about one meter high on the c# mountain. By the time you'll have finished your course, you'll know far more than I

Enjoy,
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform