none
C# how can i set the precision of the number for output

    Question

  • hi,

     

    i am a new learner in c#. i Wanna set the precision of a number for an example

    i got a number 0.12345678 but i want the output at screen is 0.12345 so how can i set the precision in C#.

    thank a lot

     

    Wednesday, June 13, 2007 8:52 AM

Answers

  •  

    Hi spirulina,

     

    Use the ToString Method. Try something like this.

                

    Code Snippet

                Double i = 0.12345678;

                System.Console.WriteLine(i.ToString("0.00000"));

     

    Hope this helps.

    Regards

    Tuesday, June 19, 2007 10:30 AM