I have a variable which is storing as decimal:
decimal firststYrComp = Int16.Parse(tb1stYr.Text.ToString());
Now I have this to get typecasted into Double? How do I do that? Thanks!
The Decimal. ToDouble() method can be used to convert a decimal to a double in C#. The Decimal. ToDouble() method converts a specified decimal value to its equivalent double-precision, floating-point number.
You can also convert a Decimal to a Double value by using the Explicit assignment operator. Because the conversion can entail a loss of precision, you must use a casting operator in C# or a conversion function in Visual Basic.
To convert a specified value to a double-precision floating-point number, use Convert. ToDouble() method. long[] val = { 340, -200}; Now convert it to Double.
You answered your own question—Just cast it to a double:
decimal x = 3.141592654M ; double pi = (double) x ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With