473,383 Members | 1,929 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,383 software developers and data experts.

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

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
--
D @ premierdata
Nov 17 '05 #1
4 1153
Should work fine as far as I can tell.

Nov 17 '05 #2
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" wrote:
Should work fine as far as I can tell.

Nov 17 '05 #3
Assuming that DataVars is of type string, are you using Split (w/a
capitol 'S') or split (w/a lower case 's')?

DEWright_CA wrote:
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" wrote:
Should work fine as far as I can tell.


Nov 17 '05 #4
that was it, I had the case wrong for split, once I caught that it started
working great!

Thanks

"Clint (cm******@online.nospam)" wrote:
Assuming that DataVars is of type string, are you using Split (w/a
capitol 'S') or split (w/a lower case 's')?

DEWright_CA wrote:
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" wrote:
Should work fine as far as I can tell.


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Roberto A. F. De Almeida | last post by:
I found that when using negative indices, the slice object passed to __getitem__ depends on the number of slices. An example to clarify: class a: def __getitem__(self, index): return index ...
4
by: F. Da Costa | last post by:
Hi, I was wondering whether someone could enlighten me as to the reason why the slice does not work in IE when the arr is passed in properly. Checked the values in the srcArr and they are...
108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
40
by: Ron Adam | last post by:
After considering several alternatives and trying out a few ideas with a modified list object Bengt Richter posted, (Thank You), I think I've found a way to make slice operation (especially far end...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
23
by: Antoon Pardon | last post by:
Now slices are objects in python, I was wondering if slice notation will be usable outside subscribtion in the future. Will it ever be possible to write things like: a = 4:9 for key, value in...
7
by: Alexandre Guimond | last post by:
Hi all, i'm trying to deepcopy a slice object but i get the following error. Does anyone know a workaround? ActivePython 2.4.3 Build 12 (ActiveState Software Inc.) based on Python 2.4.3 (#69,...
2
by: smichr | last post by:
It seems to me that the indices() method for slices is could be improved. Right now it gives back concrete indices for a range of length n. That is, it does not return any None values. Using an...
15
by: Frank | last post by:
Before I start, please let's not discuss whether goto is evil or not. For generated code, this can make perfect sense. It would be interesting to know a trick how to get C to do a goto to an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.