Barkim Barkim - 3 years ago 193
C# Question

How can I use multiple string formats in C# in a way that I am combining {0:c} and {0:n} in Writeline

For example is it possible to do

WriteLine("Statement : {0:c}", 23455);


WriteLine("Statement : {0:n}", 23455);


In one line of code using WriteLine?

Answer Source

To get the output in the format $23,455 you would use {0:c0}, the final 0 tells how many decimal places to show, it defaults to {0:c2} if you don't specify a number.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download