FieldInfo.IsFamilyAndAssembly-Eigenschaft
Ruft einen Wert ab, der angibt, ob für dieses Feld die Sichtbarkeitsstufe FamilyAndAssembly definiert ist.
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public ReadOnly Property IsFamilyAndAssembly As Boolean
'Usage
Dim instance As FieldInfo
Dim value As Boolean
value = instance.IsFamilyAndAssembly
public bool IsFamilyAndAssembly { get; }
public:
virtual property bool IsFamilyAndAssembly {
bool get () sealed;
}
/** @property */
public final boolean get_IsFamilyAndAssembly ()
public final function get IsFamilyAndAssembly () : boolean
Eigenschaftenwert
true, wenn für das Feld das FamANDAssem-Attribut festgelegt ist, andernfalls false.
Hinweise
Wenn für ein Feld die Sichtbarkeitsstufe FamilyAndAssembly definiert ist, kann es ausschließlich von den Membern einer abgeleiteten Klasse innerhalb der gleichen Assembly aufgerufen werden, nicht jedoch von anderen Typen.
Die IsFamilyAndAssembly-Eigenschaft ist festgelegt, wenn das FieldAttributes.FamANDAssem-Attribut festgelegt ist.
Beispiel
Im folgenden Beispiel wird eine Klasse erstellt, und es werden der Klassenname, der Feldname und der IsFamilyAndAssembly-Eigenschaftenwert des Felds angezeigt.
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Public Class Fieldinfo_IsFamilyAndAssembly
Protected Friend myField As String = "A protected internal field"
Public Shared Sub Main()
Dim myObject As New Fieldinfo_IsFamilyAndAssembly()
' Get the Type and FieldInfo.
Dim myType1 As Type = GetType(Fieldinfo_IsFamilyAndAssembly)
Dim myFieldInfo As FieldInfo = myType1.GetField("myField", BindingFlags.NonPublic Or BindingFlags.Instance)
' Display the class and field name and the FamilyAndAssembly property value for the field.
Console.Write(ControlChars.Lf & " Name of class: {0}", myType1.FullName)
Console.Write(ControlChars.Lf & " Value of field: {0}", myFieldInfo.GetValue(myObject))
Console.Write(ControlChars.Lf & " IsFamilyAndAssembly: {0}", myFieldInfo.IsFamilyAndAssembly)
End Sub 'Main
End Class 'Fieldinfo_IsFamilyAndAssembly
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 );
}
}
using namespace System;
using namespace System::Reflection;
public ref class Fieldinfo_IsFamilyAndAssembly
{
public protected:
String^ myField;
public:
Fieldinfo_IsFamilyAndAssembly()
{
myField = "A protected internal field";
}
};
int main()
{
Fieldinfo_IsFamilyAndAssembly^ myObject = gcnew Fieldinfo_IsFamilyAndAssembly;
// Get the Type and FieldInfo.
Type^ myType1 = Fieldinfo_IsFamilyAndAssembly::typeid;
FieldInfo^ myFieldInfo = myType1->GetField( "myField", static_cast<BindingFlags>(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
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
FieldInfo-Klasse
FieldInfo-Member
System.Reflection-Namespace
FieldAttributes-Enumeration