CLR(Common Language Runtime)্Ͱ ࣮ߦ͞ΕΔ CLRCLI(Common Language Infrastructure)ͱ͍͏ILΛωΠςΟ ϒίʔυʹม͢ΔͨΊͷ༷ͷ͜ͱɻCLIΛWindows༻ʹ࣮ ͨ͠ͷ͕CLR Linux ൛ͷ CLIΛ࣮ͨ͠ͷʹɺMonoͱ͍͏ͷ͋Δ
{ Console.WriteLine("HelloA"); } } class B : A { new public void Hello() { Console.WriteLine("HelloB"); } } static void Main(string[] args) { B b = new B(); b.Hello(); if(b is A) { A a = (A)b; a.Hello(); } }
} class B : A { new public void Hello() { Console.WriteLine("HelloB"); } } static void Main(string[] args) { B b = new B(); A a = b as A; if(a != null) a.Hello(); } ݕࠪճ1ճʹͳ͍ͬͯΔͷͰ ύϑΥʔϚϯεྑ͘ͳΔ
ConsoleProject { class TestDelegateAsync { class MainClass { public static void Main(string[] args) { TestDelegateAsync test = new TestDelegateAsync(); TestDelegate d = test.DoWork; d.BeginInvoke(test.CallbackMethod, null); Console.ReadKey(); } } public delegate int TestDelegate(); //࣮ߦ͍ͨ͠ॲཧ public int DoWork() { Console.WriteLine("DoWork"); return 100; } //AsyncCallbackͷγάωνϟʹैͬͨίʔϧόοΫϝιου public void CallbackMethod(IAsyncResult ar) { //BeginInvokeͷ݁ՌΛͬͯɺͦͷεϨου͔Β݁ՌΛநग़ͯ͠දࣔ TestDelegate @delegate = (TestDelegate)((AsyncResult)ar).AsyncDelegate; int result = @delegate.EndInvoke(ar); Console.WriteLine(result); } } } ࣮ߦ͍ͨ͠ॲཧ͕ೖΔσϦήʔτΛ༻ҙͯ͠ ࣮ߦ͍ͨ͠ॲཧΛॻ͘ γάωνϟʹैͬͨίʔϧόοΫϝιου ͜ͷΑ͏ʹͯ݁͠ՌΛಘΒΕΔ
using System.Threading; class TPL { static void Main(string[] args) { var act = new Action[10]; for (int i = 0; i < 10; ++i) act[i] = new Action(Show); //Invokeશͯྃ͢Δ·ͰϝΠϯεϨου͕ऴྃ͠ͳ͍ Parallel.Invoke(act); Console.WriteLine("exit..."); } static void Show() { Console.WriteLine("Hello."); } }