我正在尝试将一些值传递给外部类的方法以从 Windows 窗体进行计算,然后将解决方案值返回给窗体。这是我在这里声明属性的 Form1.cs
public partial class Form1 : Form
{
private string _info;
private string _info2;
private string _info3;
private string _info4;
private string _info5;
private string _info6;
public string info { set { _info = value; } get { return _info; } }
public string info2 { set { _info2 = value; } get { return _info2; } }
public string info3 { set { _info3 = value; } get { return _info3; } }
public string info4 { set { _info4 = value; } get { return _info4; } }
public string info5 { set { _info5 = value; } get { return _info5; } }
public string info6 { set { _info6 = value; } get { return _info6; } }
现在我在 button_click 事件处理程序上调用一个外部类
private void button1_Click(object sender, EventArgs e)
{
if (textBox8.Text != null && textBox9.Text != null && textBox10.Text != null && textBox11.Text != null && textBox13.Text != null)
{
AT at = new AT();
at.cal_cir(textBox8.Text, textBox9.Text, textBox10.Text, textBox11.Text, textBox13.Text);
label39.Text = _info;
label40.Text = _info2;
label41.Text = _info3;
label42.Text = _info4;
label43.Text = _info5;
label44.Text = _info6;
}
这是外部类
class AT
{ /* public string per_elon{get {return per_elon;}}
public string elongation { get { return elongation; } }
public string gauge_len { get { return gauge_len; } }
public string area { get { return area; } }
public string yield_str { get { return yield_str; } }
public string ultimate_str { get { return ultimate_str; } }*/
public void cal_cir (string a, string b, string c, string d, string e)
{
double width = Convert.ToDouble(a);
double thickness = Convert.ToDouble(b);
double final_len = Convert.ToDouble(e);
int yield = Convert.ToInt16(c);
int ultimate = Convert.ToInt16(d);
var area = width * thickness;
var gauge_len = (double)5.65 * (Math.Sqrt(area));
var elongation = final_len - gauge_len;
var per_elon = (elongation / gauge_len) * 100;
var yield_str = yield / area;
Math.Round(yield_str);
var ultimate_str = ultimate / area;
Math.Round(ultimate_str);
Form1 frm = new Form1();
frm.info = per_elon.ToString();
frm.info2 = elongation.ToString();
frm.info3 = gauge_len.ToString();
frm.info4 = area.ToString();
frm.info5 = yield_str.ToString();
frm.info6 = ultimate_str.ToString();
但它没有显示数据..请有人帮助只有这部分是至关重要的..