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 - Knockout pushing observable and computed data to an observable array -

'hasOwnProperty' in javascript -

sitecore - Resolve ISitecoreService using SimpleInjector -