Re: switch(true) in c#

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



That's just it. I'm not wanting to switch based on the value of one
variable. I am wanting to execute based on the first true condition of a
bunch of different conditions. But thanks.

Frank

"Grant Merwitz" <grant@xxxxxxxxxxxxx> wrote in message
news:%23jQwt0QmFHA.2080@xxxxxxxxxxxxxxxxxxxxxxx
> google this, maybe it can help
>
> http://cplus.about.com/library/weekly/aa022205a.htm
>
>
> but basis, which you seem to more or less have is
>
> switch(variable)
> {
> case "value" :
> //do something
> break;
> case "othervalue":
> //do something else
> break;
> default:
> //do default thing
> break;
> }
>
> "Frank" <frank.favinger@goooooogle's e-mail domain> wrote in message
> news:RdWdnZ2dnZ3vd9HknZ2dnXulb9-dnZ2dRVn-zZ2dnZ0@xxxxxxxxxxxxxxx
> > Thanks Alvin. I wish I had a help file or the C# equivalent to the WSH
> > documentation. In Visual Studio, F1 just gives me
> >
> > Help Is Not Installed for Visual Studio
> >
> > I'll see if we have MSDN where I am.
> >
> > Thanks
> >
> > "Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> wrote in message
> > news:ud57wtQmFHA.2920@xxxxxxxxxxxxxxxxxxxxxxx
> >> switch statements evaluate strings, they don't work on boolean
variables.
> >> have a look at the syntax for it in the helpfile and work your code
> >> accordingly
> >>
> >> --
> >> Regards
> >> Alvin Bruney
> >> [Shameless Author Plug]
> >> The Microsoft Office Web Components Black Book with .NET
> >> available at www.lulu.com/owc, Amazon, B&H etc
>
>> -------------------------------------------------------------------------
-
> > -----
> >>
> >>
> >> "Frank" <frank.favinger@goooooogle's e-mail domain> wrote in message
> >> news:U7GdnVQEnqK4qm_fRVn-tA@xxxxxxxxxxxxxxx
> >> > 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?
> >
> >
>
>


.


Quantcast