The code below shows how to format an integer values with positive, negative or zero values.
int positiveNumber = 1000;
Console.WriteLine(string.Format("{0:$#,###.00;($#,###.00);$0.00}",positiveNumber));
int negativeNumber = -1000;
Console.WriteLine(string.Format("{0:$#,###.00;($#,###.00);$0.00}", negativeNumber));
int zeroNumber = 0;
Console.WriteLine(string.Format("{0:$#,###.00;($#,###.00);$0.00}", zeroNumber));
outputs are:
$1,000.00
($1,000.00)
$0.00
No comments:
Post a Comment