Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How CLR handles extern method calls in C#

Tags:

c#

c#-3.0

I want to ask why all extern method calls are static? How the CLR handles these calls?

like image 353
Embedd_0913 Avatar asked Mar 15 '09 18:03

Embedd_0913


1 Answers

Extern method calls are to unmanaged code. As such, it doesn't make sense to be called on a (managed) object instance - the first (hidden) argument in an instance method is the instance reference, aka this. Typically, extern methods just involve simple types (primitives, string, etc) - not objects (except perhaps arrays - and even they are often resolved to IntPtr first).

like image 153
Marc Gravell Avatar answered Nov 14 '22 01:11

Marc Gravell