Hello,

Can someone explain me why does linker perform the resolution when function
is being defined in unmanaged code and is being used in managed code with
signatures like

public static extern Foo() .

As i understand, the function should be a static one in unmanaged code and
hence static keyword but since the static functions have only file scope, i
am not very clear what goes into making this work in an managed code.

Would be good if someone can explain this nicely for me. Internet references
don't talk about linker level resolution for this case.

A complete example is given below.
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);
  }
}

-- 
Regards,
Navneet

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to