Reflecting Members

Just as you are likely to reflect types and create instances, you will encounter scenarios where you want to explore other members of types. In this section I will demonstrate how to use Reflection to request other kinds of members.

Reflecting Methods

Type objects are used to interact with members of a type. You use Type.InvokeMember to invoke Reflected members whether those members are methods, properties, events, fields, or whatever. The key to invoking the member correctly is providing the correct information to the InvokeMember method, including the correct BindingFlags enumerated values. Listing 4.8 demonstrates how to invoke a protected method member.

Listing 4.8. Invoking a Protected Member Method by Using Reflection ...

Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.