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 191 views
191 views asked Jan 10, 2024 by avibootz
1 answer 196 views
196 views asked Mar 17, 2021 by avibootz
1 answer 208 views
208 views asked Mar 17, 2025 by avibootz
...