Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to put extension methods?
Message
From
12/09/2012 14:07:09
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01552781
Message ID:
01552791
Views:
39
This message has been marked as a message which has helped to the initial question of the thread.
Likes (1)
>>>Not yet. I think I need to discuss this with my colleagues before I'll proceed. But just for the reference, can you tell me how you have such things organized? Say, do you create a class library project in some common directory and have
>>>StringExtensions
>>>MathExtensions (for example)
>>>
>>>or just to give me an idea.
>>>
>>>Thanks again.
>>
>>
>>As Viv mentions - create a project with just extension methods if necessary
>>
>>I have a class per functionality
>>
>>
>>   ExtensionMethods 
>>       Arithmetic.cs   ( from Bill Clinton)
>>       BitOperations.cs
>>       Comparison.cs      ( eg  IsBetween() and InList() )
>>       Conversion.cs
>>
>>
>>But you are free to organize them as you like
>
>Thanks, will proceed in this direction after discussing it with colleagues as we may already have common stuff.


Right, and


(1) Put them in a separate namespace - you are then at liberty to turn them on/off for any specific class

(2) To avoid name clashes with classes in other namespaces, prefix the class names, eg

>> ExtensionMethods_Arithmetic.cs ( from Bill Clinton)
>> ExtensionMethods_ BitOperations.cs
>> ExtensionMethods_Comparison.cs ( eg IsBetween() and InList() )
>> ExtensionMethods_ Conversion.cs
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform