static void Main(string[] args) { MyClass t = new MyClass(); NonStatic myNonStatic = new NonStatic(t.Y); myNonStatic(); myNonStatic = MyClass.X; myNonStatic(); MyWrite myDelegate = new MyWrite(WriteLine); MyReadLine read = ReadLine; string str = read(); MyWrite write = WriteLine; write("myDelegate == WriteLine()"); write(str); write = Write; write("myDelegate == Write()"); write("a"); write("a"); write("a"); write("a"); WaitKey wait = ReadKey; wait(); }
//Method: Main //Purpose: Questions 3 from Unit 1 Test, delegate for Console.ReadLine() //Output: none //Restrictions: None static void Main(string[] args) { MyReadLine myReadLine; myReadLine = new MyReadLine(Console.ReadLine); string myString = myReadLine(); }
// Method: Main // Purpose: Use delegates to impersonate readline function // Restrictions: None static void Main(string[] args) { //create a var to call fns MyReadLine myReadLine; //construct delegate fns ref to point to console.readline myReadLine = new MyReadLine(Console.ReadLine); //call the new fns string readString = myReadLine(); }