CategoryMethodInfo

Assembly class

Assembly class allows us to:

  • Load assemblies
  • Explore metadata and types
  • Create instance of types

Easiest way to load assembly is by load them using following methods :

GetAssembly (requires Type variable)

GetCallingAssembly (returns Assembly from which this method has been called)

These two methods have Assembly return type. After acquiring Assembly variable we can use it to get types that we want using GetType method.

Let’s explore Assembly class:

 

MethodInfo

Type’s class GetMethods method returns us with a array of MethodInfo objects. Similarly GetMethod method provided with a name of Method returns us a  MethodInfo object. It allows us to access a lot of information and interaction concerning specific Method, such as:

Check if a method is a constructor,

Access modifier of a method,

Method parameters,

Method name,

Invoking/Calling method

And many more…

Example:

We will continue our voyage with Reflection in next lesson about Assembly class.

 

© 2019 LearnC#WithDarko

Theme by Anders NorenUp ↑