Converting Decimal to Double in C#?

RG-3 picture RG-3 · Apr 6, 2011 · Viewed 87.7k times · Source

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!

Answer

Nicholas Carey picture Nicholas Carey · Apr 6, 2011

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

decimal x  = 3.141592654M ;
double  pi = (double) x ;