1
I need to convert a value of type double
for string
in C#, without this value being changed to scientific notation.
my code is:
double valor1 = 0.000024746578864525161;
string resultado = Convert.toString(valor1);
my way out is: 2,8192381923E-15
I wanted the output to be exactly the same more in string
exit : "0.000024746578864525161";
the reasons why I need the value nay is expressed in scientific notation:
1 - I’m reading an XLSX.
2 - I am validating the values entered by the user. And in this validation, I cannot 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 notation 2,8192381923E-15 become invalid.
There is a way to make the conversion of:
double varlor = 0.000024746578864525161;
for
string resultado = "0.000024746578864525161"
and not for scientific notation:
string resultado = "2,8192381923E-15"
What are the invalid characters? You may need to change your thinking and the logic of what you are trying to do!
– Marconi
Invalid characters are in Regex
– Mik3i4a5
Don’t want to edit this to show your real output in scientific notation? The nḿero Voce puts in the output example is not the same as in the variable "value1"
– jsbueno
@Mik3i4a5 The answer solved your question? Do you think you can accept it? See [tour] if you don’t know how to do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.
– Maniero