Where and how to use the EXTERN

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Am a novice in c#, tell me about how and where i can use "Extern" Keyword
with some good example

Thansk
 
Dont hesitate while asking any question.. this is public world, ask any thing
you want to learn, dont hesitate.

Secondly, extern key word is used when you wanted to import any assembly out
side your scope, ie., not within the application.

Inother words, the dlls which are already created and you have a situation
to use them at run time, then take the assistance from Extern key word

Exmaple from MSDN

[DllImport("avifil32.dll")]
private static extern void AVIFileInit();
 
Chakravarthy said:
Dont hesitate while asking any question.. this is public world, ask any thing
you want to learn, dont hesitate.

Secondly, extern key word is used when you wanted to import any assembly out
side your scope, ie., not within the application.

It's almost never used for *assemblies* (which are managed code) - it's
almost alwyas used for using functions in unmanaged libraries.
 
A common use of it is for the Windows API. I have a class that contains
declarations like this:

internal static class API
{
[DllImport("user32.dll")]
internal static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr
wParam, IntPtr lParam);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top