예제 #1
0
        static void Main(string[] args)
        {
            Person p = new Person()
            {
                ID = 7, Name = "avi"
            };

            Console.WriteLine(p.ToString());
            Console.WriteLine(p);

            Console.WriteLine();
            Student s = new Student()
            {
                ID = 8, Name = "benny", Grade = 99, StudentNumber = 123
            };

            Console.WriteLine(s);            // reference is Object.ToString()
                                             //public void Console.WriteLine(object o)
                                             //{
                                             // o.ToString() --> console
                                             //}

            Console.WriteLine(s.ToString()); // reference is Student

            Console.WriteLine(Add(2, 3));
            //Console.WriteLine(2+3);

            Console.WriteLine(p.GetHashCode());
            Console.WriteLine(s.GetHashCode());

            Person p2 = p;

            Console.WriteLine(p2.GetHashCode() == p.GetHashCode());
            Person p3 = new Person()
            {
                ID = 7
            };

            Console.WriteLine(p.Equals(p3));//True

            Console.WriteLine(p.GetType().Name);
            Console.WriteLine(s.GetType());

            Car c = new Car()
            {
                LicensePlate = 7
            };

            Console.WriteLine(p.Equals(c));


            Console.WriteLine();

            Type t1 = p.GetType();
            Type t2 = typeof(Person);

            Console.WriteLine(t1.Name);
            Console.WriteLine(t1.IsClass);
            Console.WriteLine(t1.IsPublic);
            Console.WriteLine(t1.Namespace);

            foreach (var perMethods in t1.GetMethods())
            {
                Console.WriteLine(perMethods);
            }

            Console.WriteLine();
            foreach (var perMembers in t1.GetMembers())
            {
                Console.WriteLine(perMembers);
            }
        }