Share via

Facebook x.com LinkedIn Email

PropertyInfo.MemberType Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets a MemberTypes value indicating that this member is a property.

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

Syntax

'Declaration
Public Overrides ReadOnly Property MemberType As MemberTypes
public override MemberTypes MemberType { get; }

Property Value

Type: System.Reflection.MemberTypes
A value indicating that this member is a property.

Remarks

This property overrides MemberType. Therefore, when you examine a set of MemberInfo objects — for example, the array returned by GetMembers — the MemberType property returns MemberTypes.Property only when a given member is a property.

MemberType is a derived class of MemberInfo and specifies the type of member this is. Member types are constructors, properties, fields, and methods. Because this is a PropertyInfo property, the returned type is a property.

To get the MemberType property, first get the class Type. From the Type, get the PropertyInfo. From the PropertyInfo, get the MemberType value.

Examples

The following example displays the MemberType of a property.

Imports System.Reflection
Class Example
 Public Shared Function Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) As Integer
 outputBlock.Text &= ControlChars.CrLf & "Reflection.PropertyInfo" & vbCrLf
 ' Get the type and PropertyInfo.
 Dim MyType As Type = Type.GetType("System.Reflection.MemberInfo")
 Dim Example As PropertyInfo = MyType.GetProperty("Name")
 ' Read and display the MemberType property.
 outputBlock.Text &= "MemberType = " & _
 Example.MemberType.ToString() & vbCrLf
 Return 0
 End Function
End Class
using System;
using System.Reflection;
class Example
{
 public static int Demo(System.Windows.Controls.TextBlock outputBlock)
 {
 outputBlock.Text += "\nReflection.PropertyInfo" + "\n";
 // Get the type and PropertyInfo.
 Type MyType = Type.GetType("System.Reflection.MemberInfo");
 PropertyInfo Example = MyType.GetProperty("Name");
 // Read and display the MemberType property.
 outputBlock.Text += "\nMemberType = " + Example.MemberType.ToString();
 return 0;
 }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.


  • Last updated on 2011年11月18日