这个错误通常是因为 'SemiItemPriceBOM' 这个对象没有被实例化,所以在调用 'Add' 方法时会抛出 'NullReferenceException' 异常。可以在使用 'SemiItemPriceBOM' 之前先进行实例化操作,例如:

if (item.SemiItemPriceBOM == null)
{
    item.SemiItemPriceBOM = new List<float>();
}
item.SemiItemPriceBOM.Add(fl);

这样就可以避免在调用 'Add' 方法时出现空引用异常了。

C# 报错:System.NullReferenceException:

原文地址: https://www.cveoy.top/t/topic/mqk8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录