Esempio n. 1
0
        static void Main()
        {
            Program program = new Program();

            // call the implemented methods
            program.DisplayMessage();
            program.WriteLog("stuff is written");

            // access the interface as an object
            IInfo info = (IInfo)program;

            info.DisplayMessage();
            info.WriteLog("second try");

            // alternative syntax for accessing as object
            IInfo info2 = program as IInfo;

            info2.DisplayMessage();
            info2.WriteLog("third try");

            // call the explicit implementation
            // this is allowed only through a reference for the interface
            IInfo2 info21 = program;

            Console.WriteLine(info21.DisplayMessage());
        }