C# decimal ToString() method is at variance

c#

Solution

Decimals store the number of zeros in them (or rather, their overall precision, which can include trailing zeros):

Console.WriteLine(35m);
Console.WriteLine(35.0m);
Console.WriteLine(35.00m);
Console.WriteLine(35.000m);
Console.WriteLine(35.0000m);

... you'll see the zeros being preserved. My guess is that your row[i] really has 4 trailing zeros.

Problem

Can anybody explain what's wrong? I have row[i] that is boxed decimal and when calling "ToString()" it gives integer with 4 trailing zeros. I also have ((object)35m) that is also boxed but it gives no zeros. How it could happen? unless it's debugger issue or C# hard code I have no ideas. I'm new at stackoverflow so I can't attach images. The following url is snapshot of debugger. http://img200.imageshack.us/img200/8749/decimalissuek.jpg

Original source