简体   繁体   English

C#如何将双精度型转换为带指数符号的字符串

[英]C# how to convert a double to string with exponential notation

I'm trying to convert double to string in format of exponential notation. 我正在尝试将double转换为指数表示法格式的字符串。 for example: 例如:

double l_dNum = 3.333;
        string l_strNum = l_dNum.ToString();
        Console.WriteLine(l_strNum);
        //Wanted results: 3.33e+00

Thanks! 谢谢!

From MSDN examples MSDN示例

string l_strNum = l_dNum.ToString("E");

If you want up to 2 decimals only 如果只需要2位小数

string l_strNum = l_dNum.ToString("E2");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM