Categories

“default” keyword

Just found out today late morning about the usage of keyword “default”.
Bet it, the most popular situation to use it is when doing some logic in switch-case statement like this.

switch(num)
{
case 1:
System.Console.WriteLine("num is 1");
break;
case 2:
System.Console.WriteLine("num is 2");
break;
default:
System.Console.WriteLine("num could be others");
break;
}

It means if “num” is not 1, and 2 then the code will flow into the default [...]