_FieldInfo.IsFamilyAndAssembly プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)
構文
フィールドに FamANDAssem 属性が設定されている場合は true。それ以外の場合は false。
このプロパティは、アンマネージ コードからマネージ クラスにアクセスするためのプロパティであるため、マネージ コードからは呼び出さないでください。
IsFamilyAndAssembly プロパティは、このフィールドに FamilyAndAssembly レベルの参照範囲が設定されているかどうかを示す値を取得します。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
FieldInfo.IsFamilyAndAssembly プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)
構文
フィールドに FamANDAssem 属性が設定されている場合は true。それ以外の場合は false。
フィールドに FamilyAndAssembly レベルの参照可能範囲が設定されている場合、そのフィールドは同じアセンブリ内にある派生クラスのすべてのメンバから呼び出せますが、他の型からは呼び出せません。
IsFamilyAndAssembly プロパティは、FieldAttributes.FamANDAssem 属性が設定されたときに設定されます。
クラスを作成し、クラス名、フィールドの値、フィールドの IsFamilyAndAssembly プロパティの値を表示する例を次に示します。
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
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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- _FieldInfo.IsFamilyAndAssembly プロパティのページへのリンク