int sNum = 0; string s = "100"; int Result = 0; if(int.TryParse(s, out Result)==1)//1轉換成功 0失敗 { sNum=int.TryParse(s); } ...
- int sNum = 0;
- string s = "100";
- int Result = 0;
- int.TryParse(s, out Result) //轉換失敗Result為o 轉換成功Result為結果值
- if(Result!=0)
- {
- sNum=Result;
- }