Displays the public or non-public get accessor for the specified property. : Type « Reflection « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Reflection » Type 
19.6.5.Displays the public or non-public get accessor for the specified property.
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class Myproperty
    Private myCaption As String = "A Default caption"

    Public Property Caption() As String
        Get
            Return myCaption
        End Get
        Set(ByVal Value As String)
            If myCaption <> value Then
                myCaption = value
            End If
        End Set
    End Property
End Class

Class Mypropertyinfo
    Public Shared Function Main() As Integer
        ' Get the type and PropertyInfo for two separate properties.
        Dim MyTypea As Type = Type.GetType("Myproperty")
        Dim Mypropertyinfoa As PropertyInfo = MyTypea.GetProperty("Caption")
        Dim MyTypeb As Type = Type.GetType("System.Reflection.MethodInfo")
        Dim Mypropertyinfob As PropertyInfo = MyTypeb.GetProperty("MemberType")

        Console.WriteLine(MyTypea.FullName)
        Console.WriteLine(Mypropertyinfoa.Name)
        Console.WriteLine(Mypropertyinfoa.GetGetMethod().ToString())
        
        Console.WriteLine(MyTypeb.FullName)
        Console.WriteLine(Mypropertyinfob.Name)
        Console.WriteLine(Mypropertyinfob.GetGetMethod().ToString())

        Dim Mygetmethodinfoa As MethodInfo = Mypropertyinfoa.GetGetMethod()
        Console.WriteLine(Mypropertyinfoa.Name)
        Console.WriteLine(Mygetmethodinfoa.ReturnType.ToString())
        Dim Mygetmethodinfob As MethodInfo = Mypropertyinfob.GetGetMethod()
        Console.WriteLine(Mypropertyinfob.Name)
        Console.WriteLine(Mygetmethodinfob.ReturnType.ToString())

        Return 0
    End Function
End Class
19.6.Type
19.6.1.Retrieves the type associated with the CLSID from the local host
19.6.2.Get the method that matches the specified binding flags.
19.6.3.Use CType to convert decimal and Decimal to byte
19.6.4.Retrieve a type by passing a ProgID
19.6.5.Displays the public or non-public get accessor for the specified property.
19.6.6.Use Equals to compare two types.
19.6.7.Create an instance of a Type array representing the number, order and type of the parameters for the property.
19.6.8.Display the ClassID related to the ProgID, along with any applicable exception message.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.