PC Review


Reply
Thread Tools Rate Thread

Where and how to use the EXTERN

 
 
=?Utf-8?B?VmljdG9y?=
Guest
Posts: n/a
 
      7th May 2007
Hi,

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

Thansk
--
---------------------------------------
Knock you down in first round
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2hha3JhdmFydGh5?=
Guest
Posts: n/a
 
      7th May 2007
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();




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


"Victor" wrote:

> Hi,
>
> Am a novice in c#, tell me about how and where i can use "Extern" Keyword
> with some good example
>
> Thansk
> --
> ---------------------------------------
> Knock you down in first round

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      7th May 2007
Chakravarthy <(E-Mail Removed)> wrote:
> 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.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Brian Schwartz
Guest
Posts: n/a
 
      8th May 2007
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);
}


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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
incomptability of extern harddiskdriver Joan.M.Lee Windows Vista General Discussion 2 21st Mar 2007 06:42 PM
extern template + /Za =?Utf-8?B?U2VhbiBDb25uZXJ5?= Microsoft VC .NET 4 3rd Feb 2007 10:34 AM
[asp.net 2.0] extern aliases SirMike Microsoft ASP .NET 2 19th Jan 2007 09:17 PM
extern alias in ASP.NET 2.0 Hervé Microsoft ASP .NET 0 28th Jul 2006 08:36 PM
2 Partions on Extern HD Geddy Lee Windows XP Hardware 2 18th Mar 2004 11:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:37 AM.