But here you just have maybe which you can always check whether it's nullable or not, even if the first condition isn't true, you can still type maybe ?? 0
I mean, yes, but this is still the same. If it is not null, what is the difference you end up assigning the same value to other variable and print it, or print it straightaway in the second case. In the first case you just creating excessive variable. Result is the same
It matters when you want to pass the value to a function that accepts just int, not a nullable int. Let's say you have this : private int NoNullable(int val){ return val + val; } In order to call this function you must use one of the two ways after the if condition: NoNullable(amount); Or, NoNullable(nullable.value);
Обсуждают сегодня