Conversion of nullable double variable to String in VB.NET

Recently I came across a weird behaviour of a nullable double. As I need to turn a nullable variable into string with precisely set digits I am using method .ToString(format). When I apply this method on the aforementioned nullable variable instead of getting converted number as I need, I get only the first digit of this number (example is given bellow). Of course I can cast the nullable to double and it solves it, but why is it happening though. Thank you very much for your input.

Example:

'Nullable Double
Dim value As Double? = 867
Dim convertedValue As String = value.ToString("0.00000")
Console.WriteLine(convertedValue)
'Output: 8

'Not nullable Double
Dim value As Double = 867
Dim convertedValue As String = value.ToString("0.00000")
Console.WriteLine(convertedValue)
'Output: 867.00000


from Recent Questions - Stack Overflow https://ift.tt/3l0ElFu
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)