Exemple #1
0
        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();
        }
Exemple #2
0
        //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();
        }
Exemple #3
0
        // 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();
        }