Beispiel #1
0
        public void PrintTypeOf(Apple apple, Talk talk)
        {
            Type appleType = typeof(Apple);
            Console.WriteLine("IsArray: {0}", appleType.IsArray);
            Console.WriteLine("Name: {0}", appleType.Name);
            Console.WriteLine("IsSealed: {0}", appleType.IsSealed);
            Console.WriteLine("BaseType.Name: {0}", appleType.BaseType.Name);
            Console.WriteLine();

            Type appleGetType = apple.GetType();
            Console.WriteLine("IsArray: {0}", appleGetType.IsArray);
            Console.WriteLine("Name: {0}", appleGetType.Name);
            Console.WriteLine("IsSealed: {0}", appleGetType.IsSealed);
            Console.WriteLine("BaseType.Name: {0}", appleGetType.BaseType.Name);
            Console.WriteLine();

            Type talkType = typeof(Talk);
            Console.WriteLine("IsArray: {0}", talkType.IsArray);
            Console.WriteLine("Name: {0}", talkType.Name);
            Console.WriteLine("IsSealed: {0}", talkType.IsSealed);
            Console.WriteLine("BaseType.Name: {0}", talkType.BaseType.Name);
            Console.WriteLine();

            Type talkGetType = talk.GetType();
            Console.WriteLine("IsArray: {0}", talkGetType.IsArray);
            Console.WriteLine("Name: {0}", talkGetType.Name);
            Console.WriteLine("IsSealed: {0}", talkGetType.IsSealed);
            Console.WriteLine("BaseType.Name: {0}", talkGetType.BaseType.Name);
            Console.WriteLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("//////////////////// - Interface Demo - //////////////////// \n");
            Console.WriteLine("Apple SmartPhone:");
            Apple apple = new Apple();
            apple.OS();
            apple.AppStore();
            apple.TouchID();

            Console.WriteLine("\n\n");
            Console.WriteLine("Iphone6 SmartPhone:");
            Iphone6 iphone6 = new Iphone6();
            iphone6.TouchID();

            Console.WriteLine("\n\n");
            Console.WriteLine("Samsung SmartPhone:");
            Samsung samsung = new Samsung();
            samsung.OS();
            samsung.AppStore();

            Console.WriteLine("\n\n");
            Console.WriteLine("Toyota class");
            Toyota toyota = new Toyota();
            //toyota.yearProduction = "2000";
            //Console.WriteLine(toyota.yearProduction);
            Console.WriteLine(Toyota.yearProduction);
            Toyota.yearProduction = "2000";
            Console.WriteLine(Toyota.yearProduction);

            Console.WriteLine("\n\n");
            Console.WriteLine("Perl class");
            Console.WriteLine(Perl.price);
            Perl.price = 300;
            Console.WriteLine(Perl.price);

            Console.WriteLine("\n\n");
            Console.WriteLine("SayHello class");
            SayHello sayHello = new SayHello();
            sayHello.Speak();
            sayHello.GoodBye();
            sayHello.Yell();

            Console.WriteLine("\n\n");
            Console.WriteLine("GenericInt class");
            ArrayInt arrayInt = new ArrayInt(10);
            for (int i = 0; i < 10; i++)
            {
                arrayInt.setItem(i, i + 1);
            }
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(arrayInt.getItem(i));
            }

            //Console.WriteLine("\n\n");
            //Console.WriteLine("Repository class");
            //UserRepository userRepository = new UserRepository();
            //IEnumerable<User> ListUser = userRepository.GetAll();

            //foreach (User user in ListUser)
            //{
            //    Console.WriteLine(user.UserName);
            //}

            Console.WriteLine("\n\n");
            Console.WriteLine("Typeof class");
            TypeOf typeOf = new TypeOf();
            typeOf.PrintTypeOf(new Apple(), new SayHello());

               Console.ReadKey();
        }