这个错误说明在执行'item.SemiItemPriceBOM.Add(fl)'时,SemiItemPriceBOM属性为null,因此无法执行Add方法。

要解决这个问题,需要在使用SemiItemPriceBOM属性之前,先对其进行初始化,例如:

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

通过在使用前检查SemiItemPriceBOM属性是否为空,并进行初始化,可以避免'System.NullReferenceException'错误的发生。

C# 错误:System.NullReferenceException:

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

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