I was wondering if it was possible to conditionally break out of a case in a switch statement in C#. Take the following example.
MediaStream photoMediaStream = null;
switch (photoSize)
{
case PhotoSize.Normal:
if (imageWidth >= NormalWidth && imageWidth % NormalWidth == 0)
{
photoMediaStream = photoMedia.GetStream(new MediaOptions {Width = NormalWidth});
break;
}
case PhotoSize.Small:
if (imageWidth >= SmallWidth && imageWidth % SmallWidth == 0)
{
photoMediaStream = photoMedia.GetStream(new MediaOptions {Width = SmallWidth});
break;
}
case PhotoSize.Thumb:
if (imageWidth >= ThumbWidth && imageWidth % ThumbWidth == 0)
{
photoMediaStream = photoMedia.GetStream(new MediaOptions {Width = ThumbWidth});
break;
}
}
Basically, if the conditional is true I want to do something and then break out of the switch statement, but if not I just want to fall through to the next case.