I need to convert a value of type double
to string
in C #, without this value being changed to scientific notation.
My code is:
double valor1 = 0.000024746578864525161;
string resultado = Convert.toString(valor1);
My output is: 2,8192381923E-15
I wanted the output to be exactly the same as in string
Output: "0.000024746578864525161";
The reasons why I need not to be expressed in scientific notation are:
1 - I'm reading an XLSX.
2 - I am doing the validation of the values entered by the user. And in this validation, I can not allow invalid characters.
3 - My string is submitted to a Regex.
Regex(@"[;!*#&@?()'$~^<>ºª%\{}A-Za-z]");
4 - The fact that my Regex does not accept characters causes the number expressed in 2,8192381923E-15 notation to become invalid.
There is a way to do the conversion of:
double varlor = 0.000024746578864525161;
for
string resultado = "0.000024746578864525161"
and not for scientific notation:
string resultado = "2,8192381923E-15"