<b>(a)</b> [DllImport("libc.so.6", EntryPoint="puts", CharSet=CharSet.Ansi)] public static extern int puts(string name); <b>(b)</b> using System; using System.Runtime.InteropServices; class PInvokeTest { [DllImport("libncurses.so", EntryPoint="initscr")] public extern static void initscr(); [DllImport("libncurses.so", EntryPoint="getch")] public extern static int getch(); [DllImport("libncurses.so", EntryPoint="mvaddstr")] public extern static void mvaddstr(int x, int y, string c); [DllImport("libncurses.so", EntryPoint="endwin")] public extern static void endwin(); [DllImport("libncurses.so", EntryPoint="refresh")] public extern static void refresh(); public static void Main() { initscr(); // Initialize ncurses mvaddstr(11, 24, "Hello, from ncurses!"); mvaddstr(12, 20, "(press any key to continue)"); refresh(); getch(); // Wait for keypress endwin(); // clean up } }
Example 3: Using P/Invoke.