How to convert double to string in C#

2 Answers

0 votes
using System;

class Program
{
    static void Main() {
        double d = -1.8733E-45;
 
        string s = d.ToString();

		Console.WriteLine(s);
    }
}




/*
run:

-1.8733E-45

*/

 



answered Feb 3, 2021 by avibootz
0 votes
using System;

public static class Program
{
    public static void Main()
    {
        double n = 16.0;
        string s = n.ToString();

        Console.WriteLine(s);

        n = 16.9383;
        s = n.ToString();

        Console.WriteLine(s);
    }
}



/*
run:

16
16.9383

*/

 



answered Nov 16, 2021 by avibootz

Related questions

1 answer 130 views
1 answer 115 views
1 answer 115 views
115 views asked Jun 19, 2021 by avibootz
1 answer 119 views
119 views asked Mar 17, 2025 by avibootz
1 answer 125 views
125 views asked Nov 16, 2021 by avibootz
1 answer 154 views
154 views asked Nov 16, 2021 by avibootz
...