What is the best way to handle standard functions used everywhere

  • Thread starter Thread starter Gee
  • Start date Start date
G

Gee

I'm new to csharp and in other languages I used I have had a standard set of
useful function like QuoteString DeQuoteString which are used all over the
place. Creating a class everything I want to use it seems like lots of extra
typing.

The options I see are (Some may not be possible)
1. Create a class inherited from string and use that for my strings,
2. Use Static methods
3. Create a class every time
 
You should create a "helper" class with static methods. Good practice is to
name all these classes XxxHelper, for example MyStringHelper ... Helper
classes should only contain static methods and should never be instanciated,
so it is a good idea to add a private constructor (and no other
constructor), so that you get a compile error if you try to instanciate it
by mistake.

Bruno.
 
Bruno Jouhier said:
You should create a "helper" class with static methods. Good practice is to
name all these classes XxxHelper, for example MyStringHelper

Too long, these names need to be short cause they will be used all the time.
 
Back
Top