C# MethodInfo IsFamilyAndAssembly

Description

MethodInfo IsFamilyAndAssembly Gets a value indicating whether the visibility of this method or constructor is described by MethodAttributes.FamANDAssem; that is, the method or constructor can be called by derived classes, but only if they are in the same assembly.

Syntax

MethodInfo.IsFamilyAndAssembly has the following syntax.


public bool IsFamilyAndAssembly { get; }

Example


using System;//ww  w . j a v a 2s  . com
using System.Reflection;

public class Example
{
    public void m_public() {}
    internal void m_internal() {}
    protected void m_protected() {}
    protected internal void m_protected_public() {}

    public static void Main()
    {
        foreach (MethodBase m in typeof(Example).GetMethods(
            BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
        {
            if (m.Name.Substring(0, 1) == "m")
            {
                Console.WriteLine(m.Name);
                Console.WriteLine(m.IsFamilyAndAssembly);
            }
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo