FieldInfo.IsFamily Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets a value that indicates whether the visibility of this field is described by FieldAttributes.Family; that is, the field is visible only within its class and derived classes.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.Booleantrue if access to this field is exactly described by FieldAttributes.Family; otherwise, false.
| Exception | Condition |
|---|---|
| MethodAccessException | This member is invoked late-bound through mechanisms such as Type.InvokeMember. |
The visibility of a field is exactly described by FieldAttributes.Family if the only visibility modifier is protected. This property is false for fields that are protected internal in C# (Protected Friend in Visual Basic, protected public in C++); use the IsFamilyOrAssembly property to identify such fields.
The following example defines fields with varying levels of visibility, and displays the values of their IsAssembly, IsFamily, IsFamilyOrAssembly, and IsFamilyAndAssembly properties.
Note: |
|---|
The Visual Basic and C# languages cannot define fields with FieldAttributes.FamANDAssem visibility. |
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8.
Imports System.Reflection Public Class Example Public f_Public As Integer Friend f_Friend As Integer Protected f_Protected As Integer Protected Friend f_Protected_Friend As Integer Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) outputBlock.FontFamily = New FontFamily("Courier New") outputBlock.Text &= String.Format(vbCrLf & _ "{0,-30}{1,-18}{2}", "", "IsAssembly", "IsFamilyOrAssembly") & vbCrLf outputBlock.Text &= String.Format("{0,-21}{1,-18}{2,-18}{3}" & vbCrLf, _ "", "IsPublic", "IsFamily", "IsFamilyAndAssembly") & vbCrLf For Each f As FieldInfo In GetType(Example).GetFields( _ BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) outputBlock.Text &= String.Format("{0,-21}{1,-9}{2,-9}{3,-9}{4,-9}{5,-9}", _ f.Name, _ f.IsPublic, _ f.IsAssembly, _ f.IsFamily, _ f.IsFamilyOrAssembly, _ f.IsFamilyAndAssembly _ ) & vbCrLf Next End Sub End Class ' This code example produces output similar to the following: ' ' IsAssembly IsFamilyOrAssembly ' IsPublic IsFamily IsFamilyAndAssembly ' 'f_Public True False False False False 'f_Friend False True False False False 'f_Protected False False True False False 'f_Protected_Friend False False False True False
Note: