System.Reflection.FieldInfo.IsPublic Property

Gets a value indicating whether the field is public.

Syntax

public bool IsPublic { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Public fields are accessible everywhere their corresponding classes are visible.

The IsPublic property is set when the FieldAttributes.Public attribute is set.

To get the IsPublic property, first get the class Type. From the Type, get the FieldInfo. From the FieldInfo, get the IsPublic property. If the field is other than public, it is protected and cannot be readily accessed. To access a nonpublic field, set the BindingFlags to NonPublic, specify either BindingFlags.Instance or BindingFlags.Static, and use this for the GetField method.

Requirements

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0