The DoubleConverter class in C# is used to convert a double value to its equivalent string representation and vice versa. It is a part of the System.ComponentModel namespace.

To convert a double value to a string representation, you can use the static method DoubleConverter.ToString(). Here's an example:

double value = 3.14159;
string stringValue = DoubleConverter.ToString(value);
Console.WriteLine(stringValue); // Output: '3.14159'

To convert a string representation back to a double value, you can use the static method DoubleConverter.ToDouble(). Here's an example:

string stringValue = '3.14159';
double value = DoubleConverter.ToDouble(stringValue);
Console.WriteLine(value); // Output: 3.14159

Note that the DoubleConverter class also provides methods to convert to other types, such as Single, Int32, and Decimal.

C# DoubleConverter: Convert Double to String and Vice Versa

原文地址: https://www.cveoy.top/t/topic/pi9N 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录