C# - Decimal to Single type Conversions
When I convert Single type to Double type I want the number of zeroes to be maintained as same. For example my case is as follows
I send a request say "request1" to our clients web service "method1", the response say "response1" that I get back contains a field called "Value" that stores price value and it is of single datatype.
In my project I am storing all Price Values as Decimal DataTypes hence I convert the value of "Value" to Decimal, below is the sample code
a) oAvailRoom.oRate.cRate = Convert.ToDecimal(oRate.Price.Value.ToString());
In the above sample cRate is of decimal type and Value of Single type.
Now, I form another request say request2 using "response1" and convert Decimal to Single type as follows
b) oPriceCheck.Price.Value = Decimal.ToSingle(this.oAvailRoom.oRate.cRate);
Note: here "this.oAvailRoom.oRate.cRate = 221.2"
when I pass this request to Method2 of my clients webservice all the values needs to be same as what I have got in the previous request, if say in the previous response I get Value as "221.20" in the method2 I need to pass the same value I CANNOT PASS "221.2".
But in (a) when I convert it to decimal its becoming "221.2" which is right, but is there a way that I can maintain it as "221.20". Because in (b) I need to pass it as "221.20".