A nullable value type T?
represents all values of its underlying value type T and an additional null value.
For example, you can assign any of the following three values to a bool?
variable: true
, false
, or null
.
An underlying value type T cannot be a nullable value type itself.
Test Typing with Pattern Matching
Beginning with C# 7.0, the is operator also tests an expression result against a pattern. In particular, it supports the type pattern in the following form:
Example combining nullable value type and pattern matching:
1 | int i = 23; |
Read further here at Microsoft Docs for type testing and cast