更新时间:2023-09-13 15:45:34
听起来像数据问题,这些解决问题会停止错误,但可能会污染结果。你需要找出Allbarcodes中出错的地方[i]
1.使用TryParse,如果失败替换为0
Sound like a data issue, these work around will stop the error but it might pollute the results. You need to find out what when wrong in Allbarcodes[i]
1. Use TryParse, if failed substitute with 0
long sumOfnum = 0;
Int64.TryParse(Allbarcodes[i], out sumOfnum);
barcodeList.Add(sumOfnum);
2.在转换前检查Allbarcodes [i]是否为空
2.check if Allbarcodes[i] is empty before converting
if (!string.IsNullOrEmpty(Allbarcodes[i]) )
{
long sumOfnum = Summation(Convert.ToInt64(Allbarcodes[i]));
barcodeList.Add(sumOfnum);
}