user4912134 user4912134 - 1 year ago 79
C# Question

String Formatting in C# to handle decimal places

In the Web API there is a Number data type field we retrieve from oracle DB and return in JSON format. Since it is of Number type it shows in the result 364578.0 so now using the string format we are trying to avoid the decimal point like

serializer.Serialize(writer, string.Format("{0:n0}",reader[i]));

It did solve the issue, it does return the result omitting the decimal spaces but shows result like 364,578 I am just checking if there is any possibility that we can return the result like 364578

Answer Source

We had a little discussion in comments. You don't seem to be able to fix the problem since the API is out of your hands. That means that you have to workaround it.

From your question I understand the other end expects an integer instead of a decimal. Okay, well let's give it an int then:

serializer.Serialize(writer, Convert.ToInt32(reader[i]));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download