Gets the class that declares this member.
Assembly: mscorlib (in mscorlib.dll)
The property retrieves a reference to the Type object for the type that declares this member. A member of a type is either declared by the type or inherited from a base type, so the Type object returned by the property might not be the same as the Type object used to obtain the current MemberInfo object.
If the Type object from which this MemberInfo object was obtained did not declare this member, the property will represent one of its base types.
If the MemberInfo object is a global member (that is, if it was obtained from the Module.GetMethods method, which returns global methods on a module), the returned will be a null reference (Nothing in Visual Basic).
The following example shows how DeclaringType works with classes and interfaces and retrieves the member names of the System.IO.BufferedStream class, along with the class in which those members are declared. Also note that when B overrides virtual method M from A, it essentially redefines (or redeclares) this method. Therefore, B.M's MethodInfo reports the declaring type as B rather than A, even though A is where this method was originally declared.
DeclaringType returns only the member names and the names of their declaring types. To return the member names with their prototypes, call MemberInfo.ToString.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.