Format negatives with parentheses

J

Joe

Is there a format string to auto convert negative numbers to display in
parentheses? For example myInt.ToString("if < 0 (#) else #").

I need to pass a format to another control so I can't check the value of the
number before formatting.
 
J

John Opincar

Yes. The format string has three parts separated by semi-colon. The second
part is the format for negative numbers.

EG "$#,##0.00;($#,##0.00);Zero

John Opincar, MCAD, SCJP
(e-mail address removed)
 
J

Joe

Perfect!! Thanks.

John Opincar said:
Yes. The format string has three parts separated by semi-colon. The
second part is the format for negative numbers.

EG "$#,##0.00;($#,##0.00);Zero

John Opincar, MCAD, SCJP
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top