double和string之间
string strA;
double dB;
//字符串转换为浮点数
strA = "43.23";
dB = System.Convert.ToDouble(strA);
//浮点数转换为字符串
dB = 234.345;
strA = dB.ToString();
int和string之间
int a = 15;
string s1 = a.ToString();
string s2 = Convert.ToString(a);
string s = "18";
int a1 = int.Parse(s);
int a2;
int.TryParse(s, out a2);
int a3 = Convert.ToInt32(s);
取string字符串后几位数
string nc = "12345"
string b = nc.Remove(0, nc.Length - 2);
---b=“45”
取string字符串中某一段数据
string bb = nc.Substring(0, 4);
---bb =“1234”
c#中string与int,double等之间的类型转换
最新推荐文章于 2023-09-03 13:14:48 发布