Answers for "switch case multiple values"

C#
3

can you have multiple statement in a case c#

switch (value)
{
    case 1: case 2: case 3:          
        // Do Something
        break;
    case 4: case 5: case 6: 
        // Do Something
        break;
    default:
        // Do Something
        break;
}
Posted by: Guest on August-20-2020
0

switch case with multiple conditions

switch (measurement)
{
	case "oz":
		{
          qty = Math.round (qty * 28.3495);
          qty= (int)qty;
          measurement= "g";
          System.out.print(qty);
		}
	break;
	case "fl oz":
        {
          qty = Math.round (qty * 29.5735);
          qty= (int)qty;
          measurement= "ml";
          System.out.print(qty);
      	}
    break;
    default:
        {
          qty =(int)qty;
          System.out.print(qty);
        }
}//end switch case
Posted by: Guest on May-30-2021

C# Answers by Framework

Browse Popular Code Answers by Language