switch(code)
{
case 'A':
case 'a':
// to do
default:
// to do
}
Is there any way to merge the two "case" statements together?
You just need break;
for your current code like:
switch (code)
{
case 'A':
case 'a':
break;
// to do
default:
// to do
break;
}
but if you are comparing for upper and lower case characters then you can use char.ToUpperInvariant
and then specify cases for Upper case characters only:
switch (char.ToUpperInvariant(code))
{
case 'A':
break;
// to do
default:
// to do
break;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With