How to convert double to float in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        double d = 129341.89;
        float f = Convert.ToSingle(d);

        Console.Write(f);
    }
}



/*
run:

129341.9

*/

 



answered Aug 6, 2019 by avibootz

Related questions

1 answer 106 views
106 views asked Jan 10, 2024 by avibootz
1 answer 124 views
124 views asked Mar 17, 2021 by avibootz
1 answer 114 views
114 views asked Mar 17, 2025 by avibootz
...