判断字符串是否能转化为整形

  1.  int sNum = 0;
  2. string s = "100";  
  3. int Result = 0;  
  4. int.TryParse(s, out Result) //转换失败Result为0 转换成功Result为结果值
  5.  if(Result!=0)
  6. {
  7.     sNum=Result;
  8. }

 

posted @ 2018-01-09 16:20  敲代码带  阅读(569)  评论(1编辑  收藏  举报