Re: Can someone explain why switch syntax is the way it is?
- From: "Christof Nordiek" <cn@xxxxxxxxx>
- Date: Thu, 13 Oct 2005 16:50:48 +0200
"Andrew Ducker" <andrew@xxxxxxxxxxxxx> schrieb im Newsbeitrag
news:1129209462.752861.88480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> And no, this isn't a complaint about break - I'm very happy to make
> things explicit.
>
> However, why isn't the format something like:
>
> switch(myVariable)
> {
> case 1:
> {
> //Do Something
> }
> case 2:
> {
> //Do Something Else
> }
> default
> // Do Nothing at all
> }
>
> That way the 'break' is subsumed into the closing curly brackets, and
> it follows the same way of grouping commands as the rest of the
> language does.
>
> Andy D
>
An answer you can find on this site:
http://www.gotdotnet.com/team/csharp/learn/columns/ask.aspx#switch
The sentence that answers your question is at the end of the paragraph:
The reason this wasnt done was so that developers who were very used to C++
wouldnt have a hard time understanding what a switch statement was doing.
But I agree with you: Simply exiting a switch statement on reaching the end
of a case is much more usefull.
A good message:
This behavior could be added to C# without breaking existing programms. So,
if C#-Designers in future will agree with this, they could simply enhance C#
in that way.
.
- Prev by Date: Re: Changing permissions on NTFS file
- Next by Date: Re: Can someone explain why switch syntax is the way it is?
- Previous by thread: Re: Can someone explain why switch syntax is the way it is?
- Next by thread: Re: Can someone explain why switch syntax is the way it is?
- Index(es):
Relevant Pages
|
Loading