What is the Purpose of C# constructor extern modifier?
I know about usage of extern METHODS to invoke Win32 functions, but what about CONSTRUCTORS?
Please give the practical example.
Note this:
class MyClass
{
public extern MyClass();
}
I believe one use/purpose of an extern ctor is to have the constructor implemented within the CLR itself. if you disassemble mscorlib.dll using Reflector and look at the System.String type, you'll see:
[MethodImpl(MethodImplOptions.InternalCall)]
public extern String(char[] value);
Which basically tells us that the (char[]) ctor for the string class is externally implemented, as part of the .net runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With