赞
踩
!
null 容忍操作符(null-forgiving operator)
官方文档:! (null-forgiving) operator (C# reference) The compiler warns
that you may be dereferencing null when you write the property
message.Length because its static analysis determines that message may
be null. You may know that IsNotNull provides a null check, and when
it returns true, the null-state of message should be not-null. You
must tell the compiler those facts. One way is to use the null
forgiving operator, !. You can change the WriteLine statement to match
the following code:
它的主要作用就是告诉编译器,变量不可能为 null。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。