This article takes the following: http://blog.csdn.net/lhc1105/article/details/44279675, when we get to an object instance, we can take advantage of some of the methods provided by the type class to get basic and member information about the type:
#region get the basic information for a type people people = new people () instance of the//people class {ID = " 10086 ", Name =" LHC "}; Type T = people. GetType (); Gets the Type Object Console.WriteLine (T.name) through the instance,//Gets the name of the current Member Console.WriteLine (t.fullname);//Gets the type full Name Console.WriteLine (t.namespace);//Gets the namespace of the current Member Console.WriteLine (t.basetype);//Gets the type of the base class References to Console.WriteLine (T.underlyingsystemtype);//In. NET is a reference to the type mapped in Console.WriteLine (t.attributes);//Get TypeAttributes Bit token Console.WriteLine (t.isval Uetype);//Whether it is a value type Console.WriteLine (T.ISBYREF);//Whether it is a reference pass Console.WriteLine (t.isenum);//Whether it is an enumeration Console.WriteLine (T.isclass);//Whether it is a class Console.WriteLine (t.isinterface);//Whether it is an interface Console.WriteLine (t.issealed);//Whether it is a sealed class Console.WriteLine (t.isprimitive);//Whether it is a base type Console.WriteLine (t.isabstract);//Is abstract class Console.WriteLine (t.ispublic);//Whether public Conso Le. WriteLine (t.isnotpublic);//whether Private Console.WriteLine (t.isvisible);//assembly is visible #endregion
In addition to getting the basic information of the type, we can also get the properties of the type, fields, methods, etc. For example, you previously used Getfieldinfos to get a collection of fields and get the method with Getmethodinfos. In addition to the two used, there are methods for getting a collection of properties, constructor methods:
after these are obtained, the array is used to take the corresponding array, then a traversal operation can be performed, and if the type is passed in T, then the reflection will be more able to embody the advantage of universality.
I do not know that before you use a tool like reflector such as anti-compiler DLL, feel this kind of thing should also be done by reflection principle of it ....
Type get types Basic information Example