How to get percentage into a string in C#

2 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            double p = 0.99;

            string s = string.Format("{0:0%}", p);

            Console.WriteLine(s);
        }
    }
}


/*
run:
     
99%

*/

 



answered Dec 23, 2016 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            double p = 0.99;

            string s = string.Format("{0:0.0%}", p);

            Console.WriteLine(s);
        }
    }
}


/*
run:
     
99.0%

*/

 



answered Dec 23, 2016 by avibootz

Related questions

1 answer 202 views
1 answer 180 views
1 answer 262 views
1 answer 193 views
193 views asked Jul 30, 2023 by avibootz
1 answer 263 views
...