int comld=0; if (!int.TryParse(item.Tag.ToString(), out comld)) { continue; }
没转换成功就continue
开始写成 if(GetNumber(item.Tag.Tostring()) 还得写个 GetNumber方法 可能不太好。
本文探讨了在C#中使用TryParse方法进行字符串到整数的转换,并介绍了如何处理转换失败的情况,避免程序异常中断,通过直接跳过错误数据确保程序的稳定运行。
int comld=0; if (!int.TryParse(item.Tag.ToString(), out comld)) { continue; }
没转换成功就continue
开始写成 if(GetNumber(item.Tag.Tostring()) 还得写个 GetNumber方法 可能不太好。
转载于:https://www.cnblogs.com/Early-Bird/p/4253757.html

被折叠的 条评论
为什么被折叠?