How to display a number as a percent in .NET ?

 Posted by Bharathi Cherukuri on 8/27/2012 | Category: ASP.NET Interview questions | Views: 1233 | Points: 40

A number with any type i.e., it might be int or double or decimal, it may be displayed as a percent(%) during the output.
It can be displayed likewise as setting the format type value in the ToString() method as shown in the below example.

decimal dec = 123.554466;
string s = dec.ToString("P2");



Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response