这个错误提示说明在调用 C# item.SemiItemPriceBOM.Add(fl) 时,C# item 对象的 SemiItemPriceBOM 属性为 null,即还没有被实例化。因此,无法向其添加元素,导致出现空引用异常。

解决方法是在使用 C# item 对象之前,先实例化其 SemiItemPriceBOM 属性。例如:

if (item.SemiItemPriceBOM == null)
{
    item.SemiItemPriceBOM = new List<float>();
}
item.SemiItemPriceBOM.Add(fl);
C# 错误:System.NullReferenceException:  '对象引用未设置为对象的实例。' - SemiItemPriceBOM 属性为空

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

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