|
-
Jul 5th, 2006, 10:08 AM
#1
Thread Starter
Lively Member
Switch case-sensitive
I have this portion of code in C#.
VB Code:
switch (stripCritical)
{
case "Not critical": ratingNumber = 1; break;
case "Less critical": ratingNumber = 2; break;
case "Moderately critical": ratingNumber = 3; break;
case "Highly critical": ratingNumber = 4; break;
case "Extremely critical": ratingNumber = 5; break;
}
The problem is that if something comes accross as "Not Critical" then it doesnt match. How can I make this switch statement ignore case?
Thanks in advance.
"A candle loses nothing by lighting another candle."
-
Jul 5th, 2006, 11:14 AM
#2
Re: Switch case-sensitive
Code:
switch (stripCritical.toLower())
{
case "not critical":
Etc.
-
Jul 5th, 2006, 11:16 AM
#3
Thread Starter
Lively Member
Re: Switch case-sensitive
I should have thought of that.
Thank you very much.
Also do you know of a good web page that tells how to put a file browser on my form?
Thank you.
"A candle loses nothing by lighting another candle."
-
Jul 5th, 2006, 11:24 AM
#4
Re: Switch case-sensitive
-
Jul 5th, 2006, 11:27 AM
#5
Thread Starter
Lively Member
Re: Switch case-sensitive
Common dialog.
I have never made a file browser with code before and I would like to try on out and see how hard or easy it is.
"A candle loses nothing by lighting another candle."
-
Jul 5th, 2006, 12:06 PM
#6
Re: Switch case-sensitive
Code:
OpenFileDialog ofd = new OpenFileDialog();
if(ofd.ShowDialog() != DialogResult.Cancel)
{
MessageBox.Show(ofd.FileName);
}
Something like that?
-
Jul 5th, 2006, 01:14 PM
#7
Thread Starter
Lively Member
Re: Switch case-sensitive
Wow!
That was incredably easy.
"A candle loses nothing by lighting another candle."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|