RE: switch(true) in c#
- From: "Brad" <Brad@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 5 Aug 2005 16:31:02 -0700
None of your respondants are empathetic. Much as I disliked VB, the "select
case true" construct rocks. It is especially useful for filtering out error
conditions. Don't know of any equivalent.
Concerning help, I always use the online reference; it's always up to date.
Here's the link for C#: http://tinyurl.com/sb48
"Frank" wrote:
> 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
>
>
>
.
- References:
- switch(true) in c#
- From: Frank
- switch(true) in c#
- Prev by Date: Re: copy a datagrid cell to another
- Next by Date: Selectively removing Cache Key
- Previous by thread: Re: switch(true) in c#
- Next by thread: Re: switch(true) in c#
- Index(es):
Relevant Pages
|