Options for dynamically calling methods in C #

I saw a lot of questions related to how to call a method like this and the like. What I did not find is a list of different ways to call a method through reflection or any other means in csharp.

Can someone explain in detail the different ways to dynamically call a method in csharp? From reflection to the emission of IL and any other methods between them. I would like to know all the different ways from the most expensive to the least expensive in terms of resources.

+4
source share
1 answer

To get started, here are ways to call the .NET method that I can think of:

  • Call
  • Callvirt
  • delegate
  • Dynamicmethod
  • MethodInfo.Invoke
  • Type.InvokeMember
  • Typedescriptor
  • Reflection.Emit
  • Expression trees

I remember some article comparing the speed of most of them, but I can not find it at the moment.

A quick Google search showed the following links: [Link] [Link] [Link] [Link] [Link]

+5
source

All Articles