一、double.TryParse("1234,34,49",out temp)
这个方法用来查看字符串"1234,34,49"是不是能够转成一个double类型的数字,如果能转换成功则函数返回值为true,且用out temp来保存这个转换后的double,如果不能转换则false,temp保持原来的值不变.

 

差别就在于Parse和TryParse之中转换不匹配时,是否抛出错误. 他们之中核心的转换方法是一样的,区别大概如下:
double Parse(string value){
    try{
        if(转换失败){
            throw new FormatException(...);
       }
    }
    catch(FormatException){
    //其他判断...
    //返回其他值,或者throw;
    }
    return Nan;
}

bool TryParse(string value,out double result){
    if(转换失败){
      return false;
    }
    return true;

 

 

二、因为await 只能wait Task,并且await 只能用在async 标记的方法中,async 关键字表明这是个异步方法。

 

 

相关文章:

  • 2021-12-15
  • 2021-11-19
  • 2021-12-10
  • 2021-11-30
  • 2021-12-03
  • 2021-07-09
  • 2021-09-17
  • 2021-10-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
  • 2021-10-25
  • 2022-02-22
相关资源
相似解决方案