howto: How do I slice up a variable then run through a switch?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a variable that can be between (1) and (1,2,3,4,5) etc...

this variable shows which type of query to run, and each runs from a private
void function. I understand the method of doing but don't know enough C# yet
be able to finish.

I am trying to do something like this I think?
Should this be either a switch or a foreach type of function?

String[] optionsSelected = imageType.Split(',');
Foreach(string option in optionsSelected){
//do the building
Switch(option)
{
Case "1":
//build One
Break;
Case "2":
//build two
Break;
Default:
//build one
//build two
//build three
}
}

is this the best way to do this? or is there something that makes more sense?

Thanks
 
I keep getting the message:
'string' does not contain a definitiion for 'split'

my final line looks like this;

string[] optionselected = DataVars.imageType.split(',');

Thoughts?
Thanks for your help!
 
Assuming that DataVars is of type string, are you using Split (w/a
capitol 'S') or split (w/a lower case 's')?

DEWright_CA said:
I keep getting the message:
'string' does not contain a definitiion for 'split'

my final line looks like this;

string[] optionselected = DataVars.imageType.split(',');

Thoughts?
Thanks for your help!

Mohammad said:
Should work fine as far as I can tell.
 
that was it, I had the case wrong for split, once I caught that it started
working great!

Thanks

Clint ([email protected]) said:
Assuming that DataVars is of type string, are you using Split (w/a
capitol 'S') or split (w/a lower case 's')?

DEWright_CA said:
I keep getting the message:
'string' does not contain a definitiion for 'split'

my final line looks like this;

string[] optionselected = DataVars.imageType.split(',');

Thoughts?
Thanks for your help!

Mohammad said:
Should work fine as far as I can tell.
 
Back
Top