Concatenating C # String.Format format parameters

I would like to format my number as a percentage with an always visible sign.

To format it as a percentage I can do:

string.Format("{0:P2}", 1.45);

      

For visible signs I will do:

string.Format("{0:+#.##;-#.##;0}", 1.45);

      

Any way to combine the two?

+3


source to share


1 answer


You probably just want to add %

to your custom format :



string.Format("{0:+#.##%;-#.##%;0}", 1.45); // output +145%

      

+4


source







All Articles