PC Review


Reply
Thread Tools Rate Thread

Beginner Switch Statement Question

 
 
=?Utf-8?B?bWF0dGhldyBjdXN0ZXI=?=
Guest
Posts: n/a
 
      22nd Sep 2005
In VB I can have a switch statement with a

Case 1 to 5

in C# it seems I have to have
Case 1:
Case 2:
Case 3:
Case 4:
Case 5:

is there a short cut in C# similar to the VB to have multiple cases handled
by the one result?


 
Reply With Quote
 
 
 
 
Carlos J. Quintero [VB MVP]
Guest
Posts: n/a
 
      22nd Sep 2005
No, the "to" clause is not supported in C#.
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"matthew custer" <matthew (E-Mail Removed)> escribió en el
mensaje news:61DAC788-E1C0-4A98-89FD-(E-Mail Removed)...
> In VB I can have a switch statement with a
>
> Case 1 to 5
>
> in C# it seems I have to have
> Case 1:
> Case 2:
> Case 3:
> Case 4:
> Case 5:
>
> is there a short cut in C# similar to the VB to have multiple cases
> handled
> by the one result?
>
>



 
Reply With Quote
 
Christof Nordiek
Guest
Posts: n/a
 
      22nd Sep 2005
"matthew custer" <matthew (E-Mail Removed)> schrieb im
Newsbeitrag news:61DAC788-E1C0-4A98-89FD-(E-Mail Removed)...
> In VB I can have a switch statement with a
>
> Case 1 to 5
>
> in C# it seems I have to have
> Case 1:
> Case 2:
> Case 3:
> Case 4:
> Case 5:
>
> is there a short cut in C# similar to the VB to have multiple cases
> handled
> by the one result?
>

It's not possible with the switch-statement in C#.
You could use if-statement instead:
if (switchExpression >= 0 & switchExpression <= 5)
//Case 1 to 5
;
else if (switchExpression = ...)
//Next Case
;


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Switch Statement Question Cathleen C via DotNetMonster.com Microsoft C# .NET 2 17th Dec 2005 12:34 AM
Beginner seeks help with IF statement Ian Microsoft Excel Worksheet Functions 4 9th Apr 2005 02:46 PM
No Class at ALL!!! beginner/beginner question =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?= Microsoft ASP .NET 7 3rd Feb 2005 02:47 PM
simple switch statement question suzy Microsoft C# .NET 11 25th Apr 2004 11:02 AM
Switch Statement Question Kevin Microsoft C# .NET 1 7th Jan 2004 09:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:06 AM.