8
Answers

NP136 what is the meaning of it?

Maha

Maha

16y
2k
1

Hi Guys

 

NP136 what is the meaning of it?

 

In the following program elements in the bracket of String.Format() method (highlighted in yellow) can be unerstood as follows:

 

0 – Position of the variable

f – Floating point

3 – Number of digits

 

10 – What is the meaning of it?

 

Please explain the reason.

 

Thank you

 

using System;

 

class MainClass

{

    public static void Main()

    {

        float myFloat = 1234.56789f;

 

        string myString8 = String.Format("{0, 10:f3}", myFloat);

 

        Console.WriteLine("String.Format(\"{0, 10:f3}\", myFloat) = " + myString8);

    }

}

/*

String.Format("{0, 10:f3}", myFloat) =   1234.568

*/

 

Answers (8)