其他分享
首页 > 其他分享> > Dart类型转换

Dart类型转换

作者:互联网



void main(){

  String str = "123";
  print(int.parse(str));

  int num = 123;
  String str2 = num.toString();
  print(str2);

  String str3 = "123.1";
  print(double.parse(str3));
  String str4 = "";
  try{
    if(str4.isEmpty){
      str4 = "12";
    }
    print(double.parse(str4));
  }catch(err){
    print(err);
  }


  int Num;
  if(Num==null){
    print(0);
  }else{
    print(Num);
  }

  var Num2 = 0/0;
  if(Num2.isNaN){
    print("NuN");
  }
  print(Num2);
}

 

标签:类型转换,String,Num2,int,str4,parse,print,Dart
来源: https://blog.csdn.net/u013600907/article/details/99678114