在C#中将小数转换为双精度?
问题描述:
我有一个存储为小数的变量:
I have a variable which is storing as decimal:
decimal firststYrComp = Int16.Parse(tb1stYr.Text.ToString());
现在我要将此类型转换为Double吗?我怎么做?谢谢!
Now I have this to get typecasted into Double? How do I do that? Thanks!
答
您回答了自己的问题,只需将其转换为两倍即可:
You answered your own question—Just cast it to a double:
decimal x = 3.141592654M ;
double pi = (double) x ;