[英]Complex mathematical expression c#
I am new to c# and I want to make a pretty simple (in my opinion) program for my end of semester course.我是 c# 的新手,我想为我的期末课程制作一个非常简单(在我看来)的程序。 The algorithm in C looks like this.
C 中的算法如下所示。 It calculates debit of a fluid with Venturi effect:
它计算具有文丘里效应的流体的借方:
delta_p= p2-p1;
sectiune_rel=s1/s2;
numarator = 0.5*densitate*(pow(sectiune_rel, 2)-1);
raport = delta_p/numarator;
viteza1 = sqrt(raport);
debit = s1*viteza1;
I want to make a simple windows form with c#:我想用 c# 制作一个简单的 windows 表格:
private void Butonrezultat_Click(object sender, EventArgs e)
{
double p1, p2, densitate1, s1, s2, sectiune_rel, debit;
double.TryParse(presiunemare.Text, out p1);
double.TryParse(presiunemica.Text, out p2);
double.TryParse(densitate.Text, out densitate1);
double.TryParse(sectiunemare.Text, out s1);
double.TryParse(sectiunemica.Text, out s2);
sectiune_rel = s1 / s2;
debit = s1 * Math.Sqrt((p2 - p1) / ((0.5 * densitate1 * Math.Pow(sectiune_rel, 2) - 1)));
rezultat.Text = debit.ToString("c"). Remove(0 , 1);
}
Every time I debug it doesn't show anything to rezultat textbox.每次我调试时,rezultat 文本框都不会显示任何内容。 Do I miss something?
我错过了什么吗? I spend like two days on tutorials and I really couldn't find anything similar.
我花了两天时间在教程上,我真的找不到类似的东西。
It seems your method Butonrezultat_Click
is not attached with click event of your button.看来您的方法
Butonrezultat_Click
未附加按钮的单击事件。 Do Following跟随
Butonrezultat
in Design Mode of your Form Butonrezultat
在您的表单的设计模式中Butonrezultat
Button and search for Click
Butonrezultat
Button 的事件并搜索Click
Butonrezultat_Click
method from the drop down for click event.Butonrezultat_Click
方法,用于单击事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.