.NET FAQs Unleashed!
 
    
    

What does F2 in ToString(“F2”) mean?

The letter F instructs the compiler that the output number string would be displayed up to some fixed point places after the decimal dot. The 2 after the F signifies that the output has to be up to 2 places after the decimal dot, and the number has to be rounded.

For example

double d = 45.3920002;
string s = d.ToString(“F2”);

The output of this would be

45.39

Definition   Display 5555 as 0005555   Initialize string from a char[]   Format decimal as currency   Output int type as hexadecimal string   Display a number in exponential   Display a number as a percent   Is String a reference type   ToString("F2")    @ before double quotes   Carriage return   Escape Sequence Why do we use backslash characters with strings?   String VS. string   \u0042\u0041\u0044  

More Interview Questions.....