switch(true) in c#
- From: "Frank" <frank.favinger@goooooogle's e-mail domain>
- Date: Thu, 4 Aug 2005 11:41:24 -0400
Hi,
In classic ASP with vbscript, I'd sometimes do this.
Select case true
case x = 3
code
case y = 6
code
case r = "tick"
code
End select
In C#, is there a way of doing such a thing? The current code I have that
is /not/ valid is this.
switch(true) {
case sPN!="":
something();
break;
case sPF!="":
//something else
break;
default:
//do something different
break;
}
I know that I could do a few nested ifs, but if there are 10 different
unrelated conditions I want to test for, it could get kinda messy.
Thanks,
Frank
.
- Follow-Ups:
- Re: switch(true) in c#
- From: Ephraim
- RE: switch(true) in c#
- From: Brad
- Re: switch(true) in c#
- From: Alvin Bruney [Microsoft MVP]
- Re: switch(true) in c#
- Prev by Date: Re: datagrid with scrollbar browser compatibility problem
- Next by Date: Re: switch(true) in c#
- Previous by thread: RE POSTING Problem with a text box with custom properties in the IDE !!!HELP any MVP!!
- Next by thread: Re: switch(true) in c#
- Index(es):
Relevant Pages
|