4

I've seen quite a few questions related to how do I invoke a method like this and that. What I haven't found is a listing of the different options of how to invoke a method via reflection or any other means in csharp.

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

C. Ross
  • 31,137
  • 42
  • 147
  • 238
Sean Chambers
  • 8,572
  • 7
  • 41
  • 55

1 Answers1

5

To get you started, here are the ways to invoke a method in .NET 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't seem to find it at the moment.

A quick Google search came up with these links: [Link] [Link] [Link] [Link] [Link]

dtb
  • 213,145
  • 36
  • 401
  • 431