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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -