FieldInfo.IsFamilyAndAssembly Property

Gets a value indicating whether this field has FamilyAndAssembly level visibility.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public bool IsFamilyAndAssembly { get; }
/** @property */
public final boolean get_IsFamilyAndAssembly ()

public final function get IsFamilyAndAssembly () : boolean

Property Value

true if the field has the FamANDAssem attribute set; otherwise, false.

If a field has FamilyAndAssembly level visibility, it can be called from any member in a derived class that is also in the same assembly, but not from any other type.

The IsFamilyAndAssembly property is set when the FieldAttributes.FamANDAssem attribute is set.

The following example creates a class and displays the class name, field name, and IsFamilyAndAssembly property value of the field.

using System;
using System.Reflection;

public class Fieldinfo_IsFamilyAndAssembly
{
    protected internal string myField = "A protected internal field";
   
    public static void Main()
    {
        Fieldinfo_IsFamilyAndAssembly myObject = new 
            Fieldinfo_IsFamilyAndAssembly();

        // Get the Type and FieldInfo.
        Type myType1 = typeof(Fieldinfo_IsFamilyAndAssembly);
        FieldInfo myFieldInfo = myType1.GetField("myField",
            BindingFlags.NonPublic|BindingFlags.Instance);

        // Display the class and field name and the FamilyAndAssembly property value for the field.
        Console.Write("\n Name of class: {0}", myType1.FullName);
        Console.Write("\n Value of field: {0}", myFieldInfo.GetValue(myObject));
        Console.Write("\n IsFamilyAndAssembly: {0}", 
            myFieldInfo.IsFamilyAndAssembly );
    }
}

import System.*;
import System.Reflection.*;

public class FieldinfoIsFamilyAndAssembly
{
    protected String myField = "A protected internal field";

    public static void main(String[] args)
    {
        FieldinfoIsFamilyAndAssembly myObject = 
            new FieldinfoIsFamilyAndAssembly();

        // Get the Type and FieldInfo.
        Type myType1 = FieldinfoIsFamilyAndAssembly.class.ToType();
        FieldInfo myFieldInfo = myType1.GetField("myField", 
            BindingFlags.NonPublic | BindingFlags.Instance);

        // Display the class and field name and the FamilyAndAssembly property
        // value for the field.
        Console.Write("\n Name of class: {0}", myType1.get_FullName());
        Console.Write("\n Value of field: {0}",
            myFieldInfo.GetValue(myObject));
        Console.Write("\n IsFamilyAndAssembly: {0}",
            (System.Boolean)myFieldInfo.get_IsFamilyAndAssembly());
    } //main
} //FieldinfoIsFamilyAndAssembly

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show: