Converting Decimal to Double in C#?

后端 未结 3 1159
既然无缘
既然无缘 2021-02-06 20:21

I have a variable which is storing as decimal:

decimal firststYrComp = Int16.Parse(tb1stYr.Text.ToString());

Now I have this to get typecasted

相关标签:
3条回答
  • 2021-02-06 20:51

    You can use decimal's built in converter.

    decimal decimalValue = 5; 
    double doubleValue = decimal.ToDouble(decimalValue);
    
    0 讨论(0)
  • 2021-02-06 20:55

    Just Try

    Decimal yourDecimal = 3.222222m;
    
    Convert.ToDouble(yourDecimal);
    
    0 讨论(0)
  • 2021-02-06 21:14

    You answered your own question—Just cast it to a double:

    decimal x  = 3.141592654M ;
    double  pi = (double) x ;
    
    0 讨论(0)
提交回复
热议问题