mardi 22 mars 2016

Incosistent conversion from object to string

I have a decimal? property called Balance in a class. I have two objects of this class and value for Balance in both object is same (let's say 100). I use reflection to get value of Balance from both objects like this

object bal1= type.GetProperty("Balance").GetValue(object1);
object bal2= type.GetProperty("Balance").GetValue(object2);

When I convert the object to string then I get different values.

Console.WriteLine(bal1.ToString()); // output : 100.00
Console.WriteLine(bal2.ToString()); // output : 100

Can someone explain what is the reason behind this?





Aucun commentaire:

Enregistrer un commentaire