By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,900 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,900 IT Pros & Developers. It's quick & easy.

What is the best way to handle standard functions used everywhere

P: n/a
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
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> 2. Use Static methods

--
Michael Culley
"Gee" <so*****@microsoft.com> wrote in message news:eL**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #2

P: n/a
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.

"Gee" <so*****@microsoft.com> a écrit dans le message de
news:eL**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #3

P: n/a
> The options I see are (Some may not be possible)
1. Create a class inherited from string and use that for my strings, string is sealed - so you can't inherit from it anyway
2. Use Static methods yes to 2
3. Create a class every time

no
--
Mike Mayer - Visual C# MVP
http://www.mag37.com/csharp/
mi**@mag37.com

Nov 15 '05 #4

P: n/a
"Bruno Jouhier [MVP]" <bj******@club-internet.fr> wrote in message news:u1**************@TK2MSFTNGP10.phx.gbl...
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.

--
Michael Culley
Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.