下面的微軟官方文件介紹了C#中的?運算子
- Generics
- Nullable reference types (C# reference)
注意上面這個文件裡面的這句話:
A variable m of type T? is considered to be non-null when you apply the null-forgiving operator, as in m!.
也就是說,如果你想強制宣告一個T?物件是肯定不為null的,那麼可以使用!運算子
- Null-conditional operators ?. and ?[]
- 12.8.8 Null Conditional Member Access
下面的微軟官方文件介紹了C#中的!運算子:
- ! (null-forgiving) operator (C# reference)
- 12.8.9 Null-forgiving expressions