Пример #1
0
        static void Main(string[] args)
        {
            IPerson p1 = new Person1();

            IPerson p2 = new Person2();

            var t = p1.GetType();

            Console.WriteLine(t.GetFields()[0]); //Fields字段
            Console.WriteLine(t.GetProperties()[0]);
            Console.WriteLine(t.GetNestedTypes()[0]);
            Console.WriteLine(t.IsGenericType);
            Console.WriteLine(p2.GetType().FullName);

            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            IPerson p1 = new Person1();

            IPerson p2 = new Person2();

            var t = p1.GetType();

            Console.WriteLine(t.GetFields()[0]); //Fields字段
            Console.WriteLine(t.GetProperties()[0]);
            Console.WriteLine(t.GetNestedTypes()[0]);
            Console.WriteLine(t.IsGenericType);
            Console.WriteLine(p2.GetType().FullName);

            Console.WriteLine(typeof(IHuman).IsAssignableFrom(typeof(Person1)));
            Console.WriteLine(typeof(Person1) != typeof(IPerson));
            Console.ReadKey();
        }