Answer: </P><P align=justify>Here's a quick example of the DllImport attribute in action: using </P><P align=justify>System.Runtime.InteropServices;</P><P align=justify>class C</P><P align=justify>{</P><P align=justify>[DllImport("user32.dll")]</P><P align=justify>public static extern int MessageBoxA(int h, string m, string c, int </P><P align=justify>type);</P><P align=justify>public static int Main() </P><P align=justify>{</P><P align=justify>return MessageBoxA(0, "Hello World!", "Caption", 0);</P><P align=justify>}</P><P align=justify>}</P><P align=justify></P><P align=justify>This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA.</P><P align=justify>For more information, look at the Platform Invoke tutorial in the documentation.
Tags:Interview Questions, Microsoft, C#,
Please submit your Interview Answer for the above Question via replying to this post. Thank you for visiting to our blog, Have a Good Day!.
Sponsor Advertisement
Human Resource Management Software
Powerful, configurable software for human resources management that is easy to manage and remarkably cost-effective, whatever the size of your company. Now thereâs a smarter, more efficient way to handle all of your people-related activities. Easy-to-use system manages the full hire-to-retire lifecycle...
No comments:
Post a Comment