|
-
Jul 11th, 2005, 03:22 PM
#1
[RESOLVED] switch statement confusion
uuh I dunno how to do this but I sure do hope it's possible in C#
I have a switch and I want code execution to fall from one case to another if a certain condition isn't met
Code:
switch (something)
{
case 1:
if (val==true)
{
//do stuff;
break;
}
else
{
// go on to other case statements.... but how? it won't compile without break;
}
case 2:
case 3:
}
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 11th, 2005, 08:36 PM
#2
Re: switch statement confusion
From the VS help topic entitled "switch":
Unlike the C++ switch statement, C# does not support an explicit fall through from one case label to another. If you want, you can use goto a switch-case, or goto default.
You can fall through from one case to another only if the first case is empty.
-
Jul 11th, 2005, 08:45 PM
#3
Re: switch statement confusion
ah that sucks 
arg I don't think I should use goto
thanks for the reply
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 11th, 2005, 11:06 PM
#4
Frenzied Member
Re: switch statement confusion
I don't get it.
If you don't use break, your code will just carry one excecuting right?
Surely one can use that logic to go to the next switch if a condition is not met?
-
Jul 12th, 2005, 02:12 AM
#5
Re: switch statement confusion
 Originally Posted by StrangerInBeijing
I don't get it.
If you don't use break, your code will just carry one excecuting right?
Surely one can use that logic to go to the next switch if a condition is not met?
if you put some code in a case block, and don't use "break" you will get a compile error. It would be nice if you could do it like in C++ though
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 12th, 2005, 03:40 AM
#6
Re: switch statement confusion
You'll have to resort to if statements, evaluating both conditions...
-
Jul 12th, 2005, 02:17 PM
#7
Re: switch statement confusion
 Originally Posted by mendhak
You'll have to resort to if statements, evaluating both conditions...
REALLY?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 13th, 2005, 02:06 AM
#8
Re: switch statement confusion
 Originally Posted by MrPolite
REALLY? 
Khafesho... aqa-e-mashang
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|