【发布时间】:2020-12-19 09:42:58
【问题描述】:
我有下面的变量
int? a=null ;
string? b= null;
我需要分配 a=b ;
在 c# 9 中分配的最佳方法是什么
a= Convert.ToInt32(b);
如果字符串也为空,则分配 0 ..hw 以分配 null.. 我需要在 c# 9 中知道
编辑:感谢@john..我最终得到了以下代码
if(b is not null)
a = Convert.ToInt32(b);
【问题讨论】: