Alex P Alex P - 1 year ago 81
C# Question

Adding % sign without affecting my calculation

I'm doing the following calculation:

0.697 * 100
in C# to get a percentage
in that same formula i'd like to add a % sign without it affecting the calculation simply as a plain text character.

There must be a way to include that sign without it considering 100% but instead 100 (plus just the sign%)

Answer Source

Adding the % character to a percentage is something you do when presenting it to the user. So, you add it when displaying the info:

float perc = 0.697 * 100;
System.out.println(String.Format("{0} %", perc));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download