How can I create the dynamic type which will only accept bool
and int
?
I know this can be done manually by :
if ( smth is bool || smth is int){
dynamic myValue = smth;
}
however, can I create a type which will avoid me the manually checking, so i could directly:
dynamic myValue = smth ; //if it is not either `int` nor `bool` then throw error. otherwise, continue script.