FieldInfo.FieldType FieldInfo.FieldType FieldInfo.FieldType FieldInfo.FieldType Property

정의

이 필드 개체의 형식을 가져옵니다.Gets the type of this field object.

public:
 abstract property Type ^ FieldType { Type ^ get(); };
public abstract Type FieldType { get; }
member this.FieldType : Type
Public MustOverride ReadOnly Property FieldType As Type

속성 값

이 필드 개체의 형식입니다.The type of this field object.

구현

예제

다음 예에서는 필드를 만들고, 해당 형식을 가져옵니다 및 FieldInfo를 표시 하 고 해당 FieldType합니다.The following example creates a field, gets its type and FieldInfo, and displays its FieldType.

using namespace System;
using namespace System::Reflection;

public ref class TestClass
{
   // Define a field.
   private:
      String^ field = "private field" ;

// public:
//    Myfield()
//       : field( "private field" )
//    {}
// 
// 
//    property String^ Field 
//    {
//       String^ get()
//       {
//          return field;
//       }
// 
//   }
};

void main()
{
   TestClass^ cl = gcnew TestClass;
   
   // Get the type and FieldInfo.
   Type^ t = cl->GetType();
   FieldInfo^ fi = t->GetField("field", 
                   static_cast<BindingFlags>(BindingFlags::Instance | BindingFlags::NonPublic));
   
   // Get and display the Ftype s ieldType.
   Console::WriteLine("Field Name: {0}.{1}", t->FullName, fi->Name );
   Console::WriteLine("Field Value: '{0}'", fi->GetValue(cl));
   Console::WriteLine("Field Type: {0}", fi->FieldType);
}
// The example displays the following output:
//       Field Name: TestClass.field
//       Field Value: 'private field'
//       Field Type: System.String
using System;
using System.Reflection;

public class TestClass
{
    // Define a field.
    private string field = "private field";
}
 
public class Example
{
    public static void Main()
    {
        var cl= new TestClass();
  
        // Get the type and FieldInfo.
        Type t = cl.GetType();
        FieldInfo fi = t.GetField("field", 
            BindingFlags.Instance | BindingFlags.NonPublic);
  
        // Get and display the field type.
        Console.WriteLine("Field Name: {0}.{1}", t.FullName, fi.Name);
        Console.WriteLine("Field Value: '{0}'", fi.GetValue(cl));
        Console.WriteLine("Field Type: {0}", fi.FieldType);
    }
}
// The example displays the following output:
//       Field Name: TestClass.field
//       Field Value: 'private field'
//       Field Type: System.String
Imports System.Reflection

Public Class TestClass
    ' Define a field.
    Private field As String = "private field"
End Class 'Myfield

Public Module Example
    Public Sub Main()
        Dim cl As New TestClass()

        ' Get the type and FieldInfo.
        Dim t As Type = cl.GetType()
        Dim fi As FieldInfo = t.GetField("field", _
                 BindingFlags.Instance Or BindingFlags.NonPublic)

        ' Get and display the FieldType.
        Console.WriteLine("Field Name: {0}.{1}", t.FullName, fi.Name)
        Console.WriteLine("Field Value: '{0}'", fi.GetValue(cl))
        Console.WriteLine("Field Type: {0}", fi.FieldType)
    End Sub 
End Module
' The example displays the following output:
'       Field Name: TestClass.field
'       Field Value: 'private field'
'       Field Type: System.String

설명

형식이 몇 가지 기본 데이터 형식을 같은 String, Boolean, 또는 GUID합니다.The type is some primitive data type, such as String, Boolean, or GUID.

가져오려는 합니다 FieldType 속성을 먼저 클래스를 가져옵니다 Type합니다.To get the FieldType property, first get the class Type. Type, 가져오기는 FieldInfo합니다.From the Type, get the FieldInfo. FieldInfo, 가져오기는 FieldType 값입니다.From the FieldInfo, get the FieldType value.

적용 대상

추가 정보