Hi everyone,
I started learning C# and got totaly confused by the behaviour of the is keyword.
I understand that in the example below the value for b will be true:
In underneath example the value for for b will be false:
Somewhat logical because 10 != 20, but I thought the is keywords checks if something is of specific type and not of the same value. In other words, I expected b to be true because the literal value 20 is just also an int.
Thanks for the help!
I started learning C# and got totaly confused by the behaviour of the is keyword.
I understand that in the example below the value for b will be true:
C#:
int number = 10;
bool b = number is int;
In underneath example the value for for b will be false:
C#:
int number = 10;
bool b = number is 20
Somewhat logical because 10 != 20, but I thought the is keywords checks if something is of specific type and not of the same value. In other words, I expected b to be true because the literal value 20 is just also an int.
Thanks for the help!