DllImport in C# vs VB.NET (unmanaged DLL Import)
The following code example shows how to use the  DllImportAttribute  attribute to import the Win32  MessageBox  function. The code example then calls the imported method.  C#    using  System; using  System.Runtime.InteropServices;  class  Example {     // Use DllImport to import the Win32 MessageBox function.      [DllImport( "user32.dll" , CharSet = CharSet.Unicode)]     public  static  extern  int  MessageBox(IntPtr hWnd, String text, String caption, uint  type);      static  void  Main()     {         // Call the MessageBox function using platform invoke.          MessageBox( new  IntPtr(0), "Hello World!" , "Hello Dialog" , 0);     } }