In ToString("F2"), What does F2 mean ?

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

The output number string would be displayed upto some fixed point places after the decimal dot which is due to the instruction given by the letter F to the compiler.
The number 2 after the letter F is to display the output with 2 decimal places after the decimal dot, and the number has to be rounded.

Example:

double d = 35.3920002;
string s = d.ToString("F2");

Output:

35.39


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response