In C# 8, switch expressions were introduced. What happens if a switch expression is not exhaustive? In other words, what happens if I don't test for every possible value?
static void Main(string[] args)
{
int x = 1;
int imExhaustive = x switch
{
3 => 4,
_ => 0 // x = 1 matches this
};
int okFine = x switch
{
1 => 4 // x = 1 matches this
};
int noMatch = x switch
{
3 => 4 // No match
};
}