C# FieldInfo IsFamilyOrAssembly

Description

FieldInfo IsFamilyOrAssembly Gets a value indicating whether the potential visibility of this field is described by FieldAttributes.FamORAssem; that is, the field can be accessed by derived classes wherever they are, and by classes in the same assembly.

Syntax

FieldInfo.IsFamilyOrAssembly has the following syntax.


public bool IsFamilyOrAssembly { get; }

Example


using System;/*from  w  w  w.j  av  a2s  .c  om*/
using System.Reflection;

public class Example
{
    public int f_public;
    internal int f_internal;
    protected int f_protected;
    protected internal int f_protected_public;

    public static void Main()
    {
        foreach (FieldInfo f in typeof(Example).GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
        {
            Console.WriteLine(f.Name);
            Console.WriteLine(f.IsFamilyOrAssembly);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo