Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

Where and how to use the EXTERN

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Victor - 07 May 2007 19:49 GMT
Hi,

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

Thansk
Signature

---------------------------------------
Knock you down in first round

Chakravarthy - 07 May 2007 19:55 GMT
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();

Signature

Every thing is perfect, as long as you share!!!

> Hi,
>
> Am a novice in c#, tell me about how and where i can use "Extern" Keyword
> with some good example
>
> Thansk
Jon Skeet [C# MVP] - 07 May 2007 20:26 GMT
> 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.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Brian Schwartz - 08 May 2007 18:48 GMT
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);
}

Signature

Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.