看到案例一突然有種似曾相識的感覺XD
也許是習慣的問題 或是用在哪裡的問題
舉例我之前網頁比較常遇到的情況
string sA,sB,sC (假設這是前端傳回的value值,因為一定是字串,且剛需要轉型int)
int iA,iB,iC
if(!int.TryParse(sA))
{
Message('A錯誤');
return;
}
if(!int.TryParse(sB))
{
Message('B錯誤');
return;
}
if(!int.TryParse(sC))
{
Message('C錯誤');
return;
}
iA = int.parse(sA);
iB = int.parse(sB);
iC = int.parse(sC);