Answer: extern is a
c# keyword or modifier which calls an external method.
It is mostly used for
interop services with
DLLImport attribute. This will calls an external method from the particular
dll library.
Example,
[DllImport("User32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr i, string s1, string s2, int type);
static int Main()
{
string Name;
Console.WriteLine("Please type your message here: ");
Name = Console.ReadLine();
return MessageBox((IntPtr)0, Name, "Message Box", 0);
}
Asked In: Spotted While Learning |
Alert Moderator