Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Exception 如何在c中为可空字节分配null#_Exception - Fatal编程技术网

Exception 如何在c中为可空字节分配null#

Exception 如何在c中为可空字节分配null#,exception,Exception,当读卡器[“AC”]中存在null记录时,我想将null分配给名为AC的属性,否则通过将其解析为字节将值分配给AC。在我的例子中,AC的类型是“Byte?”,但它在上面的赋值中给出了一个错误 无法确定条件表达式的类型,因为“”和“byte”之间没有隐式转换C:\Users\Waheed Ahmed\documents\visual studio 2010\Projects\Autos\Autos\Controller\autosController.cs 274 85 Autos您可以在此处参考

当读卡器[“AC”]中存在null记录时,我想将null分配给名为AC的属性,否则通过将其解析为字节将值分配给AC。在我的例子中,AC的类型是“Byte?”,但它在上面的赋值中给出了一个错误

无法确定条件表达式的类型,因为“”和“byte”之间没有隐式转换C:\Users\Waheed Ahmed\documents\visual studio 2010\Projects\Autos\Autos\Controller\autosController.cs 274 85 Autos

您可以在此处参考

如果您确实需要将null强制转换为字节?然后使用它,就像

advert.AC = String.IsNullOrEmpty(reader["AC"].ToString()) ? null : Byte.Parse(reader["AC"].ToString());
advert.AC = String.IsNullOrEmpty(reader["AC"].ToString()) ? (Byte?)null : Byte.Parse(reader["AC"].ToString());