달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

어따 써먹을 지는 엿장수 맘대로지만 여튼 -_-.

 

namespace Ex
{
	class MainClass
	{
		static void Main(string[] args)
		{
			TestClass t = new TestClass();
 
			//TestDelegate del = () => { Console.WriteLine("Call delegate!!"); };
 
			TestDelegate del = new TestDelegate(delMethod);
			OtherDeleaget odel = () => { Console.WriteLine("Call OtherDeleaget!!"); };
			ExistParamDelegate edel = (x) => { Console.WriteLine("Call ExistParamDelegate!! Value : " + x); };
			ExistParamDelegate2 edel2 = (x, y) => { Console.WriteLine("Call ExistParamDelegate2!! Value : " + x + " Value2 : " + y); };
 
			t.Func<TestDelegate>(del);
			t.Func<OtherDeleaget>(odel);
			t.Func<ExistParamDelegate>(edel, new object[]{"100"});
			t.Func<ExistParamDelegate2>(edel2, new object[] { "100""200" });
		}
 
		static void delMethod()
		{
			Console.WriteLine("Call delMathod!!");
		}
	}
 
	delegate void TestDelegate();
	delegate void OtherDeleaget();
	delegate void ExistParamDelegate(string msg);
	delegate void ExistParamDelegate2(string msg1, string msg2);
 
	class TestClass
	{
		/*public void Func<T>(T t)
		{
			//((TestDelegate)(object)t)();
			t.GetType().GetMethod("Invoke").Invoke(t, null);
		}*/
		public void Func<T>(T t, object[] args = null)
		{
			//((TestDelegate)(object)t)();
			//object[] argss = new object[]{ };
 
			t.GetType().GetMethod("Invoke").Invoke(t, args);
		}
	}
}
Posted by 은하비류연
|