[C#] Action 제네릭 대리자

Unity3D 2013. 1. 10. 21:11
반응형

http://msdn.microsoft.com/ko-kr/library/018hxwa8(v=vs.80).aspx



using System;
using System.Windows.Forms;

public class TestAnonMethod
{
   public static void Main()
   {
      Action<string> messageTarget; 

      if (Environment.GetCommandLineArgs().Length > 1)
         messageTarget = delegate(string s) { ShowWindowsMessage(s); };
      else
         messageTarget = delegate(string s) { Console.WriteLine(s); };

      messageTarget("Hello, World!");
   }

   private static void ShowWindowsMessage(string message)
   {
      MessageBox.Show(message);      
   }
}

반응형

'Unity3D' 카테고리의 다른 글

PlayerPrefs  (0) 2013.01.15
WWW.assetbundle  (1) 2013.01.14
AssetBundle (Pro Only)  (1) 2013.01.10
Application.persistentDataPath  (0) 2013.01.10
Object.DontDestroyOnLoad  (0) 2013.01.10
: