私はC#を始めましたが、レンガの壁に当たっています。私は、次のしている
:他のクラス/スコープからvarを取得
public void button1_Click(object sender, EventArgs e)
{
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "C:\\Windows\\Microsoft.NET\\Framework\\v3.5\\csc.exe";
p.StartInfo.Arguments = textBox1.Text;
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
MessageBox.Show(output);
p.WaitForExit();
}
public void label1_Click(object sender, EventArgs e)
{
label1.Text = ;
}
どのように取得する(public void button1_Click
から)output
とlabel1
でそれを使用することができますか?
のために行くされているものであればよく、あなたは 'ます。Label1.Text =出力を使用することができます;' 'button1_Click'に。それはあなたが意味することですか?これがWinFormsアプリケーションなどの場合は、他の作業をしている間はUIスレッドをブロックしないでください。 –
'public string labelOutput {get;}のようなグローバルプロパティを定義します。 set;} 'あなたがそのプロパティに出力する代入。次にどこでも使えます – SilentCoder