c#按钮font.height可以';不能设置为双值。Can';t从双精度转换为浮点型

c#按钮font.height可以';不能设置为双值。Can';t从双精度转换为浮点型,c#,winforms,C#,Winforms,我有一个按钮名为button1。使用工具箱,我可以将按钮字体高度设置为双倍值,使用属性、字体、大小,然后设置为30.251。但是当我以编程方式设置它时,我无法编写30.251 using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { Ini

我有一个按钮名为button1。使用工具箱,我可以将按钮字体高度设置为双倍值,使用属性、字体、大小,然后设置为30.251。但是当我以编程方式设置它时,我无法编写30.251

using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
 public partial class Form1 : Form
 {
    public Form1()
    {
        InitializeComponent();
        double value=90.753/3;//the numerator & denominator came from certain computations

        Button button1 = new Button();
        button1.Font = new Font("Arial", value, FontStyle.Bold);
    }
 }
}

问题是什么?我需要一个精确的字体高度值,最多3个特定位置。它显示错误“无法从双精度转换为浮点”。

字体大小是浮点类型而不是双精度 尝试:

或者,如果该值是双重属性,请使用:

button1.Font = new Font("Arial", (float)fontSize, FontStyle.Bold);
或者如果你想早点得到电话号码

float value=(float)(90.753/3);//the numerator & denominator came from certain computations
或者更干净

float value=90.753f/3;//the numerator & denominator came from certain computations

我忘了什么。30.251来自某种计算。值=一些计算/一些计算。查看我的编辑
float value=90.753f/3;//the numerator & denominator came from certain computations