fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. Hoge(1);
  9. Hoge(2);
  10. Hoge(3);
  11. }
  12.  
  13. private static void Hoge(int n)
  14. {
  15. var commands = new List<Action>();
  16. Action commandAorB = () => Console.WriteLine("\t1 or 2.");
  17.  
  18. if (n == 1) {
  19. commands.Add(() => Console.WriteLine("\t1."));
  20. commands.Add(commandAorB);
  21. } else if (n == 2) {
  22. commands.Add(() => Console.WriteLine("\t2."));
  23. commands.Add(commandAorB);
  24. } else {
  25. commands.Add(() => Console.WriteLine("\totherwise."));
  26. }
  27.  
  28. Console.WriteLine("argument = " + n);
  29. foreach (var command in commands) {
  30. command();
  31. }
  32. }
  33. }
Success #stdin #stdout 0.04s 24000KB
stdin
Standard input is empty
stdout
argument = 1
	1.
	1 or 2.
argument = 2
	2.
	1 or 2.
argument = 3
	otherwise.