k
で作成した変数を取得または参照するにはどうすればよいbutton1_Click()
ですか?
public または static にすることはできないと考えてください。その間、この変数の値をに送信したいと思い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);
}