下面的微软官方文档介绍了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