补充提一个问题:
string a = "2.222";
double b;
b=Convert.ToDouble(a);问题:
1.如果a="C#",Convert将出错,我想当不能转换时就为0,就象VB中的Val那样.
2.怎样将double:(2.22)转换成String:(2.2200或2.2),就象VB中的Format函数那样(format(2.22,"#0.0000")).
string a = "2.222";
double b;
b=Convert.ToDouble(a);问题:
1.如果a="C#",Convert将出错,我想当不能转换时就为0,就象VB中的Val那样.
2.怎样将double:(2.22)转换成String:(2.2200或2.2),就象VB中的Format函数那样(format(2.22,"#0.0000")).
string b;
System.Console.WriteLine("{0}",a.ToString(".0000",new NumberFormatInfo()));
注意,要using System;
using System.Globalization;
你可以使用try{} catch{}就可以了
char a= "2";
int b;
b=(char)a;
a=(int)b;