Re: C# Switch statement
Absolutely, without MS products our team wouldnt exist :D
--
Duncan McNutt
Microsoft Product Deactivation Team
--
"Edward Yang" <neo_in_matrix@ msn.com> wrote in message
news:##hH3RYZDH A.1280@tk2msftn gp13.phx.gbl...[color=blue]
> Yes, there is no absolute EQUALITY in this world. So C# != C/C++. I quite
> agree.
>
> But C# borrows or inherits much of C/C++'s language infrastructures . So[/color]
what[color=blue]
> I said in my previous post is applicable to C#.
>
> BTW, what is Microsoft Product Deactivation Team? Is it funded by M$? :-p
>
> Edward
>
> "Duncan McNutt" <mutmaster@127. 0.0.22> wrote in message
> news:em6YfCXZDH A.1872@TK2MSFTN GP12.phx.gbl...[color=green]
> > C# isnt C/C++, thats the point MC++ is just a strap on for .NET C# was
> > designed from the ground up for .NET yet they left things as it was, and[/color]
> now[color=green]
> > we're gettin partial types and lambada funtions (anonymous methods)[/color][/color]
expect[color=blue][color=green]
> > spaghetii code now, generic types is the only real biggie comming in 04[/color]
> that[color=green]
> > I can see, the rest is just gonna cause more problems later on I think.
> >
> > --
> >
> > Duncan McNutt
> > Microsoft Product Deactivation Team
> > --
> >
> >
> > "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
> > news:eSg5z#WZDH A.1384@TK2MSFTN GP10.phx.gbl...[color=darkred]
> > > 1..9 or 1 to 9 seems to be 'clean' code.
> > >
> > > But, the real truth is that I think the stack of case's is cleaner[/color][/color][/color]
code.[color=blue][color=green][color=darkred]
> > >
> > > And, as a C/C++ programmer, we guard cautiously our religion[/color][/color][/color]
principles[color=blue][color=green]
> > :-).[color=darkred]
> > > We do not want to borrow something from another religion.
> > >
> > > Edward
> > >
> > > "Duncan McNutt" <mutmaster@127. 0.0.22> wrote in message
> > > news:%238uahxWZ DHA.1280@tk2msf tngp13.phx.gbl. ..
> > > > But isnt it more code clean and easier to have
> > > >
> > > > case 1..9:
> > > > or
> > > > case 1 to 9:
> > > >
> > > > instead of
> > > >
> > > > case 1:
> > > > case 2:
> > > > case 3:
> > > > case 4:
> > > > case 5:
> > > > case 6:
> > > > case 7:
> > > > case 8:
> > > > case 9:
> > > > {
> > > > blah();
> > > > break;
> > > > }
> > > >
> > > > get my drift?
> > > >
> > > > I thought C# and .net was about making it more PROBLEM orientated[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > > elegant solutions, and not house cleaning of code, well this is one[/color][/color]
> case[color=green][color=darkred]
> > > > that they have failed in my view.
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > > Duncan McNutt
> > > > Microsoft Product Deactivation Team
> > > > --
> > > >
> > > >
> > > > "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
> > > > news:ulyaMoSZDH A.1872@TK2MSFTN GP12.phx.gbl...
> > > > > OMG, I thought it is not allowed to do this!
> > > > >
> > > > > I read MSDN again, and find this:
> > > > >
> > > > > Although fall through from one case label to another is not[/color][/color]
> supported,[color=green][color=darkred]
> > > it
> > > > is
> > > > > allowed to stack case labels, for example:
> > > > > case 0:
> > > > > case 1:
> > > > > // do something;
> > > > > Edward
> > > > >
> > > > > "Stan" <stanly12spamre move@yahoo.com. au> wrote in message
> > > > > news:eFxvT3RZDH A.652@tk2msftng p13.phx.gbl...
> > > > > > Here, I did a search and copied one of the many replies to this[/color]
> > common[color=darkred]
> > > > > > question.
> > > > > > >
> > > > > >
> > > > > > Yes, like this:
> > > > > >
> > > > > > using System;
> > > > > >
> > > > > > class Test
> > > > > > {
> > > > > >
> > > > > > public static void Main()
> > > > > > {
> > > > > > int x;
> > > > > > x=Convert.ToInt 16(Console.Read Line());
> > > > > > switch (x)
> > > > > > {
> > > > > > case 1:
> > > > > > case 2:
> > > > > > case 3:
> > > > > > Console.WriteLi ne("Is 1 2 3");
> > > > > > break;
> > > > > > case 4:
> > > > > > case 5:
> > > > > > case 6:
> > > > > > Console.WriteLi ne("Is 4 5 6");
> > > > > > break;
> > > > > > default:
> > > > > > Console.WriteLi ne("Is greater than 6");
> > > > > > break;
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > However, you can't do greater than/less than (i.e. case 4 to 6)[/color][/color]
> like[color=green][color=darkred]
> > > > > > you could do in VB. You'll have to use if/else statements for[/color][/color]
> that.[color=green][color=darkred]
> > > > > >
> > > > > > 'Lib
> > > > > >
> > > > > >
> > > > > >
> > > > > > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
> > > > > > news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...
> > > > > > > Is it possible to have ranges or patterns in a case ?
> > > > > > >
> > > > > > > If not, why wasnt this designed in to make it easier instead[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > > listing
> > > > > > > every case value needed?
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > Duncan McNutt
> > > > > > > Microsoft Product Deactivation Team
> > > > > > > --
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]
Absolutely, without MS products our team wouldnt exist :D
--
Duncan McNutt
Microsoft Product Deactivation Team
--
"Edward Yang" <neo_in_matrix@ msn.com> wrote in message
news:##hH3RYZDH A.1280@tk2msftn gp13.phx.gbl...[color=blue]
> Yes, there is no absolute EQUALITY in this world. So C# != C/C++. I quite
> agree.
>
> But C# borrows or inherits much of C/C++'s language infrastructures . So[/color]
what[color=blue]
> I said in my previous post is applicable to C#.
>
> BTW, what is Microsoft Product Deactivation Team? Is it funded by M$? :-p
>
> Edward
>
> "Duncan McNutt" <mutmaster@127. 0.0.22> wrote in message
> news:em6YfCXZDH A.1872@TK2MSFTN GP12.phx.gbl...[color=green]
> > C# isnt C/C++, thats the point MC++ is just a strap on for .NET C# was
> > designed from the ground up for .NET yet they left things as it was, and[/color]
> now[color=green]
> > we're gettin partial types and lambada funtions (anonymous methods)[/color][/color]
expect[color=blue][color=green]
> > spaghetii code now, generic types is the only real biggie comming in 04[/color]
> that[color=green]
> > I can see, the rest is just gonna cause more problems later on I think.
> >
> > --
> >
> > Duncan McNutt
> > Microsoft Product Deactivation Team
> > --
> >
> >
> > "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
> > news:eSg5z#WZDH A.1384@TK2MSFTN GP10.phx.gbl...[color=darkred]
> > > 1..9 or 1 to 9 seems to be 'clean' code.
> > >
> > > But, the real truth is that I think the stack of case's is cleaner[/color][/color][/color]
code.[color=blue][color=green][color=darkred]
> > >
> > > And, as a C/C++ programmer, we guard cautiously our religion[/color][/color][/color]
principles[color=blue][color=green]
> > :-).[color=darkred]
> > > We do not want to borrow something from another religion.
> > >
> > > Edward
> > >
> > > "Duncan McNutt" <mutmaster@127. 0.0.22> wrote in message
> > > news:%238uahxWZ DHA.1280@tk2msf tngp13.phx.gbl. ..
> > > > But isnt it more code clean and easier to have
> > > >
> > > > case 1..9:
> > > > or
> > > > case 1 to 9:
> > > >
> > > > instead of
> > > >
> > > > case 1:
> > > > case 2:
> > > > case 3:
> > > > case 4:
> > > > case 5:
> > > > case 6:
> > > > case 7:
> > > > case 8:
> > > > case 9:
> > > > {
> > > > blah();
> > > > break;
> > > > }
> > > >
> > > > get my drift?
> > > >
> > > > I thought C# and .net was about making it more PROBLEM orientated[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > > elegant solutions, and not house cleaning of code, well this is one[/color][/color]
> case[color=green][color=darkred]
> > > > that they have failed in my view.
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > > Duncan McNutt
> > > > Microsoft Product Deactivation Team
> > > > --
> > > >
> > > >
> > > > "Edward Yang" <neo_in_matrix@ msn.com> wrote in message
> > > > news:ulyaMoSZDH A.1872@TK2MSFTN GP12.phx.gbl...
> > > > > OMG, I thought it is not allowed to do this!
> > > > >
> > > > > I read MSDN again, and find this:
> > > > >
> > > > > Although fall through from one case label to another is not[/color][/color]
> supported,[color=green][color=darkred]
> > > it
> > > > is
> > > > > allowed to stack case labels, for example:
> > > > > case 0:
> > > > > case 1:
> > > > > // do something;
> > > > > Edward
> > > > >
> > > > > "Stan" <stanly12spamre move@yahoo.com. au> wrote in message
> > > > > news:eFxvT3RZDH A.652@tk2msftng p13.phx.gbl...
> > > > > > Here, I did a search and copied one of the many replies to this[/color]
> > common[color=darkred]
> > > > > > question.
> > > > > > >
> > > > > >
> > > > > > Yes, like this:
> > > > > >
> > > > > > using System;
> > > > > >
> > > > > > class Test
> > > > > > {
> > > > > >
> > > > > > public static void Main()
> > > > > > {
> > > > > > int x;
> > > > > > x=Convert.ToInt 16(Console.Read Line());
> > > > > > switch (x)
> > > > > > {
> > > > > > case 1:
> > > > > > case 2:
> > > > > > case 3:
> > > > > > Console.WriteLi ne("Is 1 2 3");
> > > > > > break;
> > > > > > case 4:
> > > > > > case 5:
> > > > > > case 6:
> > > > > > Console.WriteLi ne("Is 4 5 6");
> > > > > > break;
> > > > > > default:
> > > > > > Console.WriteLi ne("Is greater than 6");
> > > > > > break;
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > However, you can't do greater than/less than (i.e. case 4 to 6)[/color][/color]
> like[color=green][color=darkred]
> > > > > > you could do in VB. You'll have to use if/else statements for[/color][/color]
> that.[color=green][color=darkred]
> > > > > >
> > > > > > 'Lib
> > > > > >
> > > > > >
> > > > > >
> > > > > > "Duncan McNutt [BSDM]" <nutmaster@127. 0.0.66> wrote in message
> > > > > > news:eNPUQtPZDH A.2352@TK2MSFTN GP12.phx.gbl...
> > > > > > > Is it possible to have ranges or patterns in a case ?
> > > > > > >
> > > > > > > If not, why wasnt this designed in to make it easier instead[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > > listing
> > > > > > > every case value needed?
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > Duncan McNutt
> > > > > > > Microsoft Product Deactivation Team
> > > > > > > --
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]
Comment