天天看點

在C#中STRING與DOUBLE/Decimal的轉換方法

string strA; 

double dB; 

//string轉換為double 

string strA = t1.get_Parameter(BuiltInParameter.RBS_DUCT_BOTTOM_ELEVATION).AsValueString();

double dB = double.Parse(strA);

//double 轉換為string 

dB = 234.345; 

strA = dB.ToString(); 

//更多時候建議使用Decimal

string angle = Math.Abs(q.AsDouble() * 180 / Math.PI).ToString();

decimal needCheck = Decimal.Parse(angle);