473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

What is the best way to handle standard functions used everywhere

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
4 1074
> 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
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
> 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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
28
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are...
12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
4
by: atv | last post by:
Whatis the proper way to handle errors from function calls? For example, i normally have a main function, with calls to mine or c functions. Should i check for errors in the functions called...
2
by: Thomas G. Marshall | last post by:
Arthur J. O'Dwyer <ajo@nospam.andrew.cmu.edu> coughed up the following: > On Thu, 1 Jul 2004, Thomas G. Marshall wrote: >> >> Aside: I've looked repeatedly in google and for some reason cannot >>...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
67
by: neilcancer | last post by:
i come from china,and i'm sorry that my english is very poor. now i'm studing data structure and i met some problem about c language. could you tell me what will happen after i use free()? i...
29
by: VirtualDev | last post by:
What is the future of C++?, and what is the C++0x? and is it really going to include a standard portable libraries for GUI, networking, embedded systems and so on?
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.