c# remove trailing 0 for INR currency conversion? -


i use following code convert input comma separated string in inr:

decimal input = 1111111111.59m; string result = input.tostring("c", new cultureinfo("en-in")); 

i want remove trailing 0s now, how do this?

for example:

decimal input = 1111111111.00m; output should 1111111111 

string result = input.tostring("c0", new cultureinfo("en-in"));

update:

so want output "123.45" input 123.45 , output "123" input 123.00. can't achieve these 2 different formats without conditional operator, string.format() produce 1 output format you.

the code simple though:

string format = decimal.round(input) == input ? "c0" : "c"; string output = input.tostring(format); 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -