我有類似下面的浮點值,轉換浮動字符串有四個數值
20.0
我想20.0值轉換爲類似下面的字符串,
20.0000
結果必然是,
if float 20.0 than string must be 20.0000
if float 10.0 than string must be 10.0000
我該如何轉換浮點值( 20.0)改爲字符串值(20.0000)?
任何幫助將不勝感激。代碼我現在有:
//worksheet.Cells[j, 7].Value = sonuc1.Unit.ToString() != "" ? (CellValue)sonuc1.Unit : ""; var deneme1 = Convert.ToDecimal(sonuc1.Unit);
var deneme2 = Convert.ToDouble(sonuc1.Unit);
var deneme3 = double.Parse("0.01000");
var deneme = sonuc1.Unit;
worksheet.Cells[j, 7].Value = sonuc1.Unit.ToString() != "" ? (CellValue)sonuc1.Unit : "";
我希望你可以幫忙,因爲你很內行。 //worksheet.Cells [j,7] .Value = sonuc1.Unit.ToString()!=「」? (CellValue)sonuc1.Unit:「」; var deneme1 = Convert.ToDecimal(sonuc1.Unit); var deneme2 = Convert.ToDouble(sonuc1.Unit); var deneme3 = double.Parse(「0.01000」); var deneme = sonuc1.Unit; worksheet.Cells [j,7] .Value = sonuc1.Unit.ToString()!=「」? (CellValue)sonuc1.Unit:「」; – user3635828
'float f = 10.0f; f.ToString(「00.0000」,CultureInfo.InvariantCulture)// 10.000' –
'10f.ToString(「F4」,CultureInfo.InvariantCulture)' –