Use the extern modifier in a method declaration to indicate that the method is implemented externally. A common use of the extern modifier is with the DllImport attribute.
For example
using System; using System.Runtime.InteropServices; class MyClass { [DllImport("User32.dll")] public static extern int MessageBox(int h, string m, string c, int type); public static int Main() { string myString;
Console.Write("Enter your message: ");
myString = Console.ReadLine(); return MessageBox(0, myString, "My Message Box", 0); } }In this above example, the program receives a string from the user and displays it inside a message box. The program uses theMessageBoxmethod imported from theUser32.dlllibrary Extern is nothing but a memory storage type.If we declare extern before the function than the variable can be accessed by that function not only locally but externally too.
extern int a=4 Int fun (int x) { x=a;} print gives a=4
Twitter
Facebook
Digg
Delicious
Stumble

4 comments:
I also do agree with the stuff you shared, Thanks that's a wonderful post.
PIC Bonus
Very informative article post. Fantastic.
PIC Scheme
nice blog!
pic scheme singapore
I like this post, enjoyed this one regards for posting .
PIC Claim
Post a Comment