What is the best way to handle standard functions used everywhere

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
 
B

Bruno Jouhier [MVP]

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.
 
M

Michael Culley

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top