dimanche 28 avril 2019

Using multiple 'is' variables in a single if statement

Assuming the following if-statement, when using the is keyword with multiple OR conditions, Is there a way to find out which condition passed the evaluation without having to check the values in separate or nested if-statements?

if (value is int xint
 || value is double xdouble
 || value is decimal xdecimal)
{
    // do with value
}

Aucun commentaire:

Enregistrer un commentaire