简体   繁体   English

复数数学表达式 c#

[英]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跟随

  1. Select your button Butonrezultat in Design Mode of your Form Select 您的按钮Butonrezultat在您的表单的设计模式中
  2. Click on Events button on top of Properties Window.单击属性 Window 顶部的事件按钮。
  3. Scroll the events of Butonrezultat Button and search for Click滚动Butonrezultat Button 的事件并搜索Click
  4. Select Butonrezultat_Click method from the drop down for click event.下拉菜单中的 Select Butonrezultat_Click方法,用于单击事件。
  5. Run Your Code运行你的代码

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM