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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -