fork download
  1. using System;
  2.  
  3. public partial class Form1 : Form
  4. {
  5. Class1 class1;
  6. public Form1()
  7. {
  8. InitializeComponent();
  9. //出力用テキストボックスを引数で処理用クラスに渡す。
  10. class1 = new Class1(outputTextBox);
  11. }
  12.  
  13. private void button1_Click(object sender, EventArgs e)
  14. {
  15. class1.test();
  16.  
  17. }
  18. }
  19.  
  20.  
  21.  
  22. //処理用クラス
  23. class Class1
  24. {
  25. TextBox textBox;
  26. public Class1(TextBox textBox)
  27. {
  28. //Form1クラスから出力用のテキストボックスを受け取る。
  29. this.textBox = textBox;
  30. }
  31. public void test()
  32. {
  33. textBox.AppendText("処理しています……" + "\r\n");
  34. for (int i = 5; i >= 1; i--)
  35. {
  36. textBox.AppendText("あと" + i + "秒" + "\r\n");
  37. Thread.Sleep(1000);
  38. }
  39. textBox.AppendText("処理完了!");
  40. }
  41. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(3,34): error CS0246: The type or namespace name `Form' could not be found. Are you missing an assembly reference?
prog.cs(25,9): error CS0246: The type or namespace name `TextBox' could not be found. Are you missing an assembly reference?
prog.cs(26,23): error CS0246: The type or namespace name `TextBox' could not be found. Are you missing an assembly reference?
Compilation failed: 3 error(s), 0 warnings
stdout
Standard output is empty