この PropertyInfo オブジェクトがリフレクションするプロパティの type を取得します。
Overrides Public ReadOnly Property MemberType As MemberTypes
[C#]
public override MemberTypes MemberType {get;}
[C++]
public: __property MemberTypes get_MemberType();
[JScript]
public override function get MemberType() : MemberTypes;
プロパティ値
プロパティの型を表す MemberTypes オブジェクト。
解説
MemberType は MemberInfo の派生クラスで、このメンバの型を指定します。メンバ型には、コンストラクタ、プロパティ、フィールド、およびメソッドがあります。 PropertyInfo プロパティであるため、戻り値の型はプロパティです。
MemberType プロパティを取得するには、最初に Type クラスを取得します。そして、その Type から PropertyInfo を取得します。 PropertyInfo から MemberType 値を取得します。
使用例
指定したメンバの型を表示する例を次に示します。
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Class Mypropertyinfo
Public Shared Function Main() As Integer
Console.WriteLine(ControlChars.CrLf & "Reflection.PropertyInfo")
' Get the type and PropertyInfo.
Dim MyType As Type = Type.GetType("System.Reflection.MemberInfo")
Dim Mypropertyinfo As PropertyInfo = MyType.GetProperty("Name")
' Read and display the MemberType property.
Console.WriteLine("MemberType = " & _
Mypropertyinfo.MemberType.ToString())
Return 0
End Function
End Class
[C#]
using System;
using System.Reflection;
class Mypropertyinfo
{
public static int Main()
{
Console.WriteLine("\nReflection.PropertyInfo");
// Get the type and PropertyInfo.
Type MyType = Type.GetType("System.Reflection.MemberInfo");
PropertyInfo Mypropertyinfo = MyType.GetProperty("Name");
// Read and display the MemberType property.
Console.Write("\nMemberType = " + Mypropertyinfo.MemberType.ToString());
return 0;
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
int main()
{
Console::WriteLine(S"\nReflection.PropertyInfo");
// Get the type and PropertyInfo.
Type* MyType = Type::GetType(S"System.Reflection.MemberInfo");
PropertyInfo* Mypropertyinfo = MyType->GetProperty(S"Name");
// Read and display the MemberType property.
Console::Write(S"\nMemberType = {0}", __box(Mypropertyinfo->MemberType));
return 0;
}
[JScript]
import System;
import System.Reflection;
class Mypropertyinfo
{
public static function Main() : void
{
Console.WriteLine("\nReflection.PropertyInfo");
//Get the type and PropertyInfo
var MyType : Type = Type.GetType("System.Reflection.MemberInfo");
var Mypropertyinfo : PropertyInfo = MyType.GetProperty("Name");
//Read and display the MemberType property
Console.Write("\nMemberType = " + Mypropertyinfo.MemberType.ToString());
}
}
Mypropertyinfo.Main();
/*
Produces the following output
Reflection.PropertyInfo
MemberType = Property
*/
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
PropertyInfo クラス | PropertyInfo メンバ | System.Reflection 名前空間