FieldInfo.MemberType 속성
이 멤버가 필드임을 나타내는 MemberTypes 값을 가져옵니다.
네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)
구문
‘선언
Public Overrides ReadOnly Property MemberType As MemberTypes
‘사용 방법
Dim instance As FieldInfo
Dim value As MemberTypes
value = instance.MemberType
public override MemberTypes MemberType { get; }
public:
virtual property MemberTypes MemberType {
MemberTypes get () override;
}
/** @property */
public MemberTypes get_MemberType ()
public override function get MemberType () : MemberTypes
속성 값
이 멤버가 필드임을 나타내는 MemberTypes 값입니다.
설명
이 속성은 MemberType을 재정의합니다. 따라서 MemberInfo 개체의 집합(예: GetMembers에서 반환된 배열)을 조사할 때, MemberType 속성은 지정된 멤버가 필드인 경우에만 MemberTypes.Field를 반환합니다.
예제
다음 예제에서는 지정된 멤버가 필드인지 여부를 확인하고 그 결과를 표시합니다.
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
' Make a field.
Public Class Myfield
Private m_field As String = "a private field"
Public ReadOnly Property Field() As String
Get
Return m_field
End Get
End Property
End Class
Public Class Myfieldinfo
Public Shared Sub Main()
Console.WriteLine()
Console.WriteLine(ControlChars.Cr & "Reflection.FieldInfo")
Console.WriteLine()
Dim Myfield As New Myfield()
' Get the Type and FieldInfo.
Dim MyType As Type = GetType(Myfield)
Dim Myfieldinfo As FieldInfo = _
MyType.GetField("m_field", BindingFlags.NonPublic Or BindingFlags.Instance)
' Get and display the MemberType.
Console.Write(ControlChars.Cr & "{0}.", MyType.FullName)
Console.Write("{0} - ", Myfieldinfo.Name)
Console.Write("{0};", Myfield.Field)
Dim Mymembertypes As MemberTypes = Myfieldinfo.MemberType
Console.Write("MemberType is a {0}.", Mymembertypes.ToString())
End Sub
End Class
using System;
using System.Reflection;
// Make a field.
public class Myfield
{
private string field = "a private field";
public string Field
{
get{return field;}
}
}
public class Myfieldinfo
{
public static int Main()
{
Console.WriteLine ("\nReflection.FieldInfo");
Myfield Myfield = new Myfield();
// Get the Type and FieldInfo.
Type MyType = typeof(Myfield);
FieldInfo Myfieldinfo = MyType.GetField("field", BindingFlags.NonPublic|BindingFlags.Instance);
// Get and display the MemberType.
Console.Write ("\n{0}.", MyType.FullName);
Console.Write ("{0} - ", Myfieldinfo.Name);
Console.Write ("{0};", Myfield.Field);
MemberTypes Mymembertypes = Myfieldinfo.MemberType;
Console.Write("MemberType is a {0}.", Mymembertypes.ToString());
return 0;
}
}
using namespace System;
using namespace System::Reflection;
// Make a field.
public ref class Myfield
{
private:
String^ field;
public:
Myfield()
: field( "a private field" )
{}
property String^ Field
{
String^ get()
{
return field;
}
}
};
int main()
{
Console::WriteLine( "\nReflection.FieldInfo" );
Myfield^ myfield = gcnew Myfield;
// Get the Type and FieldInfo.
Type^ MyType = Type::GetType( "Myfield" );
FieldInfo^ Myfieldinfo = MyType->GetField( "field", static_cast<BindingFlags>(BindingFlags::NonPublic | BindingFlags::Instance) );
// Get and display the MemberType.
Console::Write( "\n{0}.", MyType->FullName );
Console::Write( "{0} - ", Myfieldinfo->Name );
Console::Write( "{0};", myfield->Field );
MemberTypes Mymembertypes = Myfieldinfo->MemberType;
Console::Write( "MemberType is a {0}.", Mymembertypes );
return 0;
}
import System.*;
import System.Reflection.*;
// Make a field.
public class MyField
{
private String field = "a private field";
/** @property
*/
public String get_Field()
{
return field;
} //get_Field
} //MyField
public class MyFieldInfo
{
public static void main(String[] args)
{
Console.WriteLine("\nReflection.FieldInfo");
MyField myField = new MyField();
// Get the Type and FieldInfo.
Type myType = Type.GetType("MyField");
FieldInfo myFieldInfo = myType.GetField("field",
BindingFlags.NonPublic | BindingFlags.Instance);
// Get and display the MemberType.
Console.Write("\n{0}.", myType.get_FullName());
Console.Write("{0} - ", myFieldInfo.get_Name());
Console.Write("{0};", myField.get_Field());
MemberTypes myMemberTypes = myFieldInfo.get_MemberType();
Console.Write("MemberType is a {0}.", myMemberTypes.ToString());
} //main
} //MyFieldInfo
import System;
import System.Reflection;
//Make a field
public class Myfield
{
private var field : String = "a private field";
public function get Field() : String {
return field;
}
}
public class Myfieldinfo
{
public static function Main() : void
{
Console.WriteLine ("\nReflection.FieldInfo");
var myfield : Myfield = new Myfield();
//Get the Type and FieldInfo
var MyType : Type = Type.GetType("Myfield");
var Myfieldinfo : FieldInfo = MyType.GetField("field", BindingFlags.NonPublic|BindingFlags.Instance);
//Get and Display the MemberType
Console.Write ("\n{0}.", MyType.FullName);
Console.Write ("{0} - ", Myfieldinfo.Name);
Console.Write ("{0};", myfield.Field);
var Mymembertypes : MemberTypes = Myfieldinfo.MemberType;
Console.Write(" MemberType is a {0}", Mymembertypes.ToString());
}
}
Myfieldinfo.Main();
이 코드는 다음과 같이 출력됩니다.
Reflection.FieldInfo
Myfield.field - a private field; MemberType is a Field
플랫폼
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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
.NET Compact Framework
2.0, 1.0에서 지원
참고 항목
참조
FieldInfo 클래스
FieldInfo 멤버
System.Reflection 네임스페이스
FieldInfo 클래스
Type