Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: Infos, links, best practice etc. for programming a webservice Pin
KaptinKrunch1-Apr-08 14:05
KaptinKrunch1-Apr-08 14:05 
GeneralRe: Infos, links, best practice etc. for programming a webservice Pin
Rob Philpott1-Apr-08 22:45
Rob Philpott1-Apr-08 22:45 
Question(XML) Editing a single element within a node Pin
Stupefy1-Apr-08 10:13
Stupefy1-Apr-08 10:13 
GeneralRe: (XML) Editing a single element within a node Pin
damianrda1-Apr-08 10:56
damianrda1-Apr-08 10:56 
GeneralRe: (XML) Editing a single element within a node Pin
Stupefy1-Apr-08 11:03
Stupefy1-Apr-08 11:03 
GeneralRe: (XML) Editing a single element within a node Pin
led mike1-Apr-08 11:04
led mike1-Apr-08 11:04 
GeneralRe: (XML) Editing a single element within a node Pin
led mike1-Apr-08 10:59
led mike1-Apr-08 10:59 
QuestionA style question regarding multi-signature methods Pin
Clive D. Pottinger1-Apr-08 9:19
Clive D. Pottinger1-Apr-08 9:19 
Hello all.

Now that I have discovered extension methods, I am revisiting my libraries of handy-dandy routines to see where it makes sense to convert them. In doing so I am also revisiting a question about how to handle methods that work on different data types.

I am wondering if anyone out there has any opinions or knows any arguments for/against writing such methods in a particular style. I know there probably isn't any one "right" answer, but I thought it would be informative to hear what other programmers think.

For instance, I have a lot of methods that work on strings. I also need the same operations to work on character arrays. So I might end up with something like
public int foo ( char[] SourceData ) { ... }
public int foo ( string SourceData ) { ... }

I have also handled this using
public int foo ( char[] SourceData ) { return foo(new string(SourceData)); }
public int foo ( string SourceData ) { ... }

and even
public int foo ( object SourceData ) 
{
  string source;
  if ( SourceData.GetType() == typeof(string) ) source = SourceData;
  else if ( SourceData.GetType() == typeof(char[]) ) source = new string(SourceData); 
  else error_condition;
  ...
}

I started to look at generics, but it seems that they may be a bit of overkill for routines that only handle 2 or 3 different data types.

Opinions? Critisisms? Other ideas? All are welcome.

Clive Pottinger
Victoria, BC

GeneralRe: A style question regarding multi-signature methods Pin
Pete O'Hanlon1-Apr-08 9:28
mvePete O'Hanlon1-Apr-08 9:28 
GeneralRe: A style question regarding multi-signature methods Pin
led mike1-Apr-08 9:43
led mike1-Apr-08 9:43 
GeneralRe: A style question regarding multi-signature methods Pin
Pete O'Hanlon1-Apr-08 22:01
mvePete O'Hanlon1-Apr-08 22:01 
GeneralRe: A style question regarding multi-signature methods Pin
Clive D. Pottinger2-Apr-08 4:03
Clive D. Pottinger2-Apr-08 4:03 
GeneralRe: A style question regarding multi-signature methods Pin
led mike2-Apr-08 5:14
led mike2-Apr-08 5:14 
GeneralIndividual Tooltip on each ColumnHeader on a ListView Pin
jchalfant1-Apr-08 8:58
jchalfant1-Apr-08 8:58 
GeneralCrystal reports 'Running total fields' Pin
NewToAspDotNet1-Apr-08 8:57
NewToAspDotNet1-Apr-08 8:57 
AnswerRe: Crystal reports 'Running total fields' Pin
jchalfant1-Apr-08 9:03
jchalfant1-Apr-08 9:03 
Generalimage processing Pin
kanza azhar1-Apr-08 7:30
kanza azhar1-Apr-08 7:30 
GeneralRe: image processing Pin
led mike1-Apr-08 7:42
led mike1-Apr-08 7:42 
GeneralRe: image processing Pin
B.Tanner1-Apr-08 7:50
B.Tanner1-Apr-08 7:50 
GeneralRe: image processing Pin
led mike1-Apr-08 8:07
led mike1-Apr-08 8:07 
GeneralRe: image processing Pin
kanza azhar2-Apr-08 3:58
kanza azhar2-Apr-08 3:58 
GeneralRegular Expression getting image tag source from HTML string Pin
Baro1-Apr-08 7:30
Baro1-Apr-08 7:30 
GeneralRe: Regular Expression getting image tag source from HTML string Pin
pmarfleet1-Apr-08 8:43
pmarfleet1-Apr-08 8:43 
GeneralRe: Regular Expression getting image tag source from HTML string Pin
Baro1-Apr-08 11:05
Baro1-Apr-08 11:05 
GeneralRe: Regular Expression getting image tag source from HTML string Pin
pmarfleet1-Apr-08 19:43
pmarfleet1-Apr-08 19:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.