如何在c#中尝试catch,以便在try catch中执行sql查询
有时count的值为0,它会将错误除以零错误.因此当它抛出除以零错误时,我必须执行一个sql语句来删除该语句,并且循环必须继续获取下一条记录的值.我该怎么做.
double value = (read * 100 / count);
Run Code Online (Sandbox Code Playgroud)
Dar*_*rov 29
当你可以简单地测试值count
是否等于0 时,为什么要进行try/catch :
if (count != 0)
{
// perform the division only if count is different than 0,
// otherwise we know that it will throw an exception
// so why even attempting it?
double value = (read * 100 / count);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
37547 次 |
最近记录: |