Type.GetProperty searches for the public property with the specified name and return type. : Type « Reflection « VB.Net






Type.GetProperty searches for the public property with the specified name and return type.

 

Imports System
Imports System.Reflection
Class MyClass1
    Private myMessage As [String] = "Hello World."
    Public Property MyProperty1() As String
        Get
            Return myMessage
        End Get
        Set(ByVal Value As String)
            myMessage = Value
        End Set
    End Property
End Class

Class TestClass
    Shared Sub Main()
        Try
            Dim myType As Type = GetType(MyClass1)
            Dim myStringProperties1 As PropertyInfo = myType.GetProperty("MyProperty1", GetType(String))
            Console.WriteLine(myStringProperties1.Name)
            Console.WriteLine(myStringProperties1.PropertyType.ToString())
        Catch e As ArgumentNullException
            Console.WriteLine("ArgumentNullException :" + e.Message.ToString())
        Catch e As AmbiguousMatchException
            Console.WriteLine("AmbiguousMatchException :" + e.Message.ToString())
        Catch e As NullReferenceException
            Console.WriteLine("Source : {0}", e.Source.ToString())
            Console.WriteLine("Message : {0}", e.Message.ToString())
        End Try
    End Sub 
End Class 

   
  








Related examples in the same category

1.Get method from Type
2.Type.GetElementType returns the Type of the object referred to
3.Type.IsArray Property gets a value indicating whether the Type is an array.
4.Type.IsGenericTypeDefinition
5.Type.IsInstanceOfType determines whether the specified object is an instance of the current Type.
6.Type.IsInterface tells whether the Type is an interface; that is, not a class or a value type.
7.Type.IsNested
8.Type.IsNestedAssembly
9.Type.IsNestedFamily Property tells whether the Type is nested and visible only within its own family.
10.Type.IsNestedPrivate Property
11.Type.IsNestedPublic Property tells whether a class is nested and declared public.
12.Type.IsPublic Property tells whether the Type is declared public.
13.Type.IsSealed Property tells whether the Type is declared sealed.
14.Type.IsSerializable Property tells indicating whether the Type is serializable.
15.Type.IsSubclassOf
16.Type.IsValueType Property tells whether the Type is a value type.
17.Type.IsVisible Property tells whether the Type can be accessed by code outside the assembly.
18.Type Class Represents type declarations
19.Type.Assembly Property
20.Type.AssemblyQualifiedName Property
21.Type.Attributes Property gets the attributes associated with the Type.
22.Type.BaseType Property gets the type from which the current Type directly inherits.
23.Type.ContainsGenericParameters
24.Type.DeclaringMethod gets a MethodBase
25.Assign the Integer type to the type parameter of the Example method
26.Invoke generic method
27.Type.DeclaringType gets the type that declares the current nested type or generic type parameter.
28.Type.DefaultBinder gets a reference to the default binder
29.Type.Equals
30.Type.Equals Method (Type)
31.Type.FilterAttribute represents the member filter used on attributes. This field is read-only.
32.Type.FilterNameIgnoreCase Field
33.Type.FindInterfaces returns interfaces implemented or inherited by the current Type.
34.Type.FindMembers
35.Type.FullName gets the fully qualified name of the Type
36.Type.GenericParameterPosition gets the position of the type parameter
37.Type.GetArrayRank gets the number of dimensions in an Array.
38.Type.GetConstructor (BindingFlags, Binder, Type[], ParameterModifier[])
39.Type.GetConstructor (Type[])
40.Type.GetConstructors (BindingFlags)
41.Get Constructors with Binding flags
42.Type.GetElementType returns the Type of the object encompassed or referred
43.Type.GetEvent returns the EventInfo object representing the specified public event.
44.Type.GetEvents (BindingFlags)
45.Type.GetEvents returns all the public events that are declared or inherited by the current Type.
46.Type.GetField searches for the public field with the specified name.
47.Type.GetFields (BindingFlags)
48.Type.GetFields returns all the public fields of the current Type.
49.Type.GetGenericTypeDefinition
50.Type.GetInterface
51.Type.GetInterfaces
52.Type.GetMember searches for the public members with the specified name.
53.Type.GetMember searches for the specified members, using the specified binding constraints.
54.Type.GetMember (String, MemberTypes, BindingFlags)
55.Type.GetMembers (BindingFlags)
56.Type.GetMembers returns all the public members of the current Type.
57.Type.GetMethod Method
58.Type.GetMethod searches for the specified method, using the specified binding constraints.
59.Type.GetMethod with modifiers, binding constraints and calling convention.
60.Get MethodA(ByVal i() As Integer)
61.Get MethodA(ByRef r As Integer)
62.Get MethodA(ByVal i As Integer, ByRef o As Integer)
63.Type.GetMethod get methods by public method whose parameters match the specified argument types.
64.Get MethodA(i As Integer())
65.Get MethodA(ByRef r As Integer)
66.Get MethodA(i As Integer, ByRef r As Integer)
67.Type.GetMethods (BindingFlags)
68.Type.GetNestedTypes (BindingFlags)
69.Type.GetNestedTypes returns the public types nested in the current Type.
70.Type.GetProperties (BindingFlags)
71.Get the nonpublic properties
72.Type.GetProperties returns all the public properties of the current Type.
73.Type.GetProperty (String) searches for the public property with the specified name.
74.Type.GetProperty (String, BindingFlags) searches property, using the specified binding constraints.
75.Type.GetProperty get properties by parameters types and modifiers.
76.Type.GetProperty searches for public property whose parameters match the specified argument types.
77.Type.GetType Method gets the Type with the specified name, performing a case-sensitive search.
78.Type.GetTypeFromCLSID (Guid) gets the type associated with the specified class identifier (CLSID).
79.Type.GetTypeFromCLSID (Guid, Boolean)
80.Type.GetTypeFromCLSID (Guid, String)
81.Type.GetTypeFromCLSID Method (Guid, String, Boolean)
82.Type.GetTypeFromHandle gets the type referenced by the specified type handle.
83.Type.GetTypeFromProgID (String, Boolean)
84.Type.GetTypeFromProgID gets type with program identifier (progID) from the specified server
85.Type.GetTypeHandle gets the handle for the Type of a specified object.
86.Type.GUID Property gets the GUID associated with the Type.
87.Type.HasElementType tells whether the current Type encompasses or refers to another type
88.Creates the type 'array of Example
89.Gets the Test method, defined above, and examines its parameters
90.Create pointer and ByRef types to use when you define method parameters
91.Type.HasElementTypeImpl: Determine whether a variable refers to an array or pointer or reference type
92.Determine whether myType is an array, pointer, reference type
93.Invokes specified member, using binding constraints and matching the specified argument list.
94.Type.IsAbstract tells whether the Type is abstract and must be overridden.
95.Type.IsAnsiClass tells whether the string format attribute AnsiClass is selected for the Type.
96.Type.IsArray tells whether the Type is an array.
97.Type.IsArrayImpl tells whether the Type is an array.
98.Type.IsAssignableFrom
99.Is generics assignable
100.Type.IsAutoLayout tells whether the class layout attribute AutoLayout is selected for the Type.
101.Type.IsClass tells whether the Type is a class; that is, not a value type or interface.
102.Type.IsContextful Property tells whether the Type can be hosted in a context.
103.Determine whether the types are marshalled by reference
104.Determine whether the types are primitive datatypes
105.Type.IsEnum Property tells whether the current Type represents an enumeration.
106.Type.MakeArrayType returns an array of the current type with the specified number of dimensions.
107.Create a Type object that represents a two-dimensional array of Example objects
108.Demonstrate an exception when an invalid array rank is specified
109.Create a Type object that represents a ByRef parameter of type Example
110.Type.Missing Field represents a missing value in the Type information.
111.Type.Module Property gets the module (DLL) in which the current Type is defined.
112.Type.ReflectedType Property gets the class object that was used to obtain this member.
113.Viewing Type Information
114.Lists all the public constructors of the System.String class.
115.Reflection.MemberInfo
116.Display information about the GetValue method of FieldInfo.
117.Lists all the members of the System.IO.BufferedStream class.