June 2003
Intermediate to advanced
800 pages
34h 20m
English
You want to invoke a method or set a property that’s named in a string.
Use the Type.InvokeMember method.
The Type class provides an InvokeMember method that’s similar to the CallByName function in Visual Basic 6. It requires the object; the name of the field, property, or method (as a string); a flag that indicates whether the string corresponds to a field, property, or method; and an array of objects for any required parameters. For example, you can call a method with no arguments using this syntax:
Dim MyObject As New MyClass() Dim TypeInfo As Type = MyObject.GetType() ' Call Refresh() on MyObject. Dim Args() As Object = {} TypeInfo.InvokeMember("Refresh", BindingFlags.Public Or _ BindingFlags.InvokeMethod, ...Read now
Unlock full access