using System; using System.Collections.Generic; public class Test { public static void Main() { Hoge(1); Hoge(2); Hoge(3); } private static void Hoge(int n) { var commands = new List(); Action commandAorB = () => Console.WriteLine("\t1 or 2."); if (n == 1) { commands.Add(() => Console.WriteLine("\t1.")); commands.Add(commandAorB); } else if (n == 2) { commands.Add(() => Console.WriteLine("\t2.")); commands.Add(commandAorB); } else { commands.Add(() => Console.WriteLine("\totherwise.")); } Console.WriteLine("argument = " + n); foreach (var command in commands) { command(); } } }