The easiest way yo do this is to use the C# decimal type.
decimal amount = (decimal)myReader["Amount"];
I had tried double and float, and they both gave me an explicit conversion error.
FYI: when initializing a decimal, use this:
decimal mynumber=0m;
Think of the "m" as "money".
In format strings, use {0:C} (currency format) to display.
string.format("{0:C}",amount);
Bryan Valencia is a contributing editor and founder of Visual Studio Journey. He owns and operates Software Services, a web design and hosting company in Manteca, California.
No comments:
Post a Comment