如何获取或引用k
我在其中创建的变量button1_Click()
?
考虑到我不能让它公开或静态。同时,我希望将此变量的值发送到textbox.text
;
如何才能做到这一点?
public delegate string fac(int x);
public static fac intostring = factory;
public static string factory(int x)
{
string inst = x.ToString();
return inst;
}
public class MyClass
{
static public string s = intostring(/*here*/);
public string Text;
public MyClass(Form Form1)
{
var textbox = Form1.Controls.Find("textBox1", true).FirstOrDefault();
Text = ((TextBox)textbox).Text = (s);
}
}
private void button1_Click(object sender, EventArgs e)
{
int k = 1;
intostring(k);
MyClass my = new MyClass(this);
}