C# MethodInfo DeclaringType

Description

MethodInfo DeclaringType Gets the class that declares this member.

Syntax

MethodInfo.DeclaringType has the following syntax.


public abstract Type DeclaringType { get; }

Example


using System;/*  w  w  w.  j a va2s.  c o  m*/
using System.IO;
using System.Reflection;

namespace MyNamespace2 
{
    class Mymemberinfo 
    { 

        public static void Main(string[] args) 
        { 
            Type MyType =Type.GetType("System.IO.BufferedStream");
            MemberInfo[] Mymemberinfoarray = MyType.GetMembers();

            Console.WriteLine("\nThere are {0} members in {1}.", Mymemberinfoarray.Length, MyType.FullName); 

            foreach (MemberInfo Mymemberinfo in Mymemberinfoarray) 
            {  
                Console.WriteLine("Declaring type of {0} is {1}.", Mymemberinfo.Name, Mymemberinfo.DeclaringType); 
            }
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo