Mat*_*ard 10 c# visual-studio .net-6.0 c#-10.0 c#-11.0
根据 CA1062,外部可见方法中需要进行 null 检查,如下所示:
public static double GetLongitude(this Location location)
{
if(location is null)
{
throw new ArgumentNullException(nameof(location));
}
return location.Longitude;
}
Run Code Online (Sandbox Code Playgroud)
我现在已经更新到.net 6.0并尝试使用参数null检查“!!”:
public static double GetLongitude(this Location location!!) => location.Longitude;
Run Code Online (Sandbox Code Playgroud)
但这又抛出了CA1062。
希望你们能帮助我:-)
| 归档时间: |
|
| 查看次数: |
3220 次 |
| 最近记录: |