Last post Sep 13, 2012 10:03 PM by hassanmehmood
Sep 13, 2012 09:57 PM|zippyfly|LINK
Ok, I know I will get told to use google to search for my answer but I did and can't find what I am looking to do.
first off, I am out of school at the moment and hopefully will get back sometime soon. So in the meantime, I am trying to keep on top of C#, mainly because I didn't grasp it the first time, so I am going thru each chapter on my own time to try and learn
My question deals with casting,I think.
I am trying to convert to a Integer from a Decimal equation.......
"turnover(this is to be a Integer) = cost of goods / average inventory(this is to be expressed as a dollar amount)."
When I mouse over that equation it gives me this message..... Cannot implicitly convert type 'decimal' to 'int'. An explicit conversion exists(Are you missing a cast?).
I am lost and any help would be appreciated.
Sep 13, 2012 10:03 PM|hassanmehmood|LINK
The Error occurs, because ur division function returns a decimal result. But u have an integer on the left side. So it is asking u to do a type casting
decimal cost_of_goods = 14.56M;
decimal avg_inventory = 12;
int turnover = (int) ( cost_of_goods / avg_inventory );
Hope this helps..