Freigeben über


PropertyInfo.PropertyType-Eigenschaft

Ruft den Typ dieser Eigenschaft ab.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public MustOverride ReadOnly Property PropertyType As Type
'Usage
Dim instance As PropertyInfo
Dim value As Type

value = instance.PropertyType
public abstract Type PropertyType { get; }
public:
virtual property Type^ PropertyType {
    Type^ get () abstract;
}
/** @property */
public abstract Type get_PropertyType ()
public abstract function get PropertyType () : Type

Eigenschaftenwert

Der Typ dieser Eigenschaft.

Hinweise

Type ist String, Boolean, Int32 usw.

Um die PropertyType-Eigenschaft abzurufen, rufen Sie zunächst den Type der Klasse ab. Über Type rufen Sie PropertyInfo ab. Aus PropertyInfo rufen Sie den PropertyType-Wert ab.

Beispiel

Im folgenden Beispiel wird der Datentyp der angegebenen Eigenschaft angezeigt.

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Namespace MyNamespace
    Public Class Example
        Public ReadOnly Property Answer As Integer
            Get
                Return 42
            End Get
        End Property

        Public Shared Sub Main()
            ' Get a Type object for the Example type.
            Dim t As Type = GetType(MyNamespace.Example) 

            ' Get a PropertyInfo object for the Answer property.
            Dim pi As PropertyInfo = t.GetProperty("Answer")

            ' Display the type returned by the Answer property.
            Console.WriteLine("The return type of the {0}.{1} property is {2}.", _
                t.Name, pi.Name, pi.PropertyType)

        End Sub
    End Class
End Namespace
using System;
using System.Reflection;

namespace MyNamespace
{
    public class Example
    {
        public int Answer        
        {
            get
            {
                return 42;
            }
        }

        public static void Main()
        {
            // Get a Type object for the Example type.
            Type t = typeof(MyNamespace.Example);

            // Get a PropertyInfo object for the Answer property.
            PropertyInfo pi = t.GetProperty("Answer");

            // Display the type returned by the Answer property.
            Console.WriteLine("The return type of the {0}.{1} property is {2}.",
                t.Name, pi.Name, pi.PropertyType);
        }
    }
}

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

PropertyInfo-Klasse
PropertyInfo-Member
System.Reflection-Namespace