コード例 #1
0
 static void Main(string[] args)
 {
     First.Hello  h1 = new First.Hello();
     Second.Hello h2 = new Second.Hello();
     h1.hello();
     h2.hello();
     Console.ReadKey();
 }
コード例 #2
0
        static void Main(string[] args)
        {
            First.Hello  h1 = new First.Hello();
            Second.Hello h2 = new Second.Hello();
            h1.sayHello();
            h2.sayHello();

            First.Hello h3 = new First.Hello();
            Welcome     w3 = new Welcome();

            h3.sayHello();
            w3.sayWelcome();

            Console.WriteLine();

            PublicTest publicTest = new PublicTest();

            Console.WriteLine("Hello " + publicTest.name);
            publicTest.Msg("Nicer name");

            ProtectedTest protectedTest = new ProtectedTest();
            //Console.WriteLine("Hello " + protectedTest.name); //Inaccessible due to protected
            //protectedTest.Msg("More protected name lol");     //Inaccessible due to protected

            Program program = new Program();

            Console.WriteLine("Hello " + program.name);
            program.Msg("Even more protected name xd");

            InternalTest internalTest = new InternalTest();

            Console.WriteLine("Hello " + internalTest.name);
            internalTest.Msg("More internal name");

            ProtectedInternalTest protectedInternalTest = new ProtectedInternalTest();

            Console.WriteLine("Hello " + protectedInternalTest.name);
            protectedInternalTest.Msg("More protected internal name");

            PrivateTest privateTest = new PrivateTest();

            //Console.WriteLine("Hello " + privateTest.name); //Inaccessible due to private
            //privateTest.Msg("More protected name");         //Inaccessible due to private

            Console.WriteLine("Hello " + program.name);
            program.Msg("More inside private name");

            Student student = new Student();

            student.ID    = "1";
            student.Name  = "Ali Baba";
            student.Email = "*****@*****.**";

            Console.WriteLine("ID: " + student.ID);
            Console.WriteLine("Name: " + student.Name);
            Console.WriteLine("Email: " + student.Email);
        }