C# 4.0 の名前付きパラメーターとオプション パラメーター


   //C# 4.0 の新機能である名前付きパラメーターとオプション パラメーターはメソッド オーバーロードの代わりに使用できます 
   class Sample5
   {
       class MyClass
       {
           public List<object> Search(
               string name = "*",
               int age = -1,
               string city = "*")
           {
               Console.WriteLine(name + " " + age + " " + city);
               return null;
           }
       }
       public Sample5()
       {
           MyClass c = new MyClass();
           c.Search("TARO", city: "TOKYO");
       }
   }
最終更新:2012年05月28日 23:39