int* ptr = stackalloc int[10]; IntPtr intptr = (IntPtr)ptr;
[DllImport("mydll.dll")] static extern void MyFunction(IntPtr arg1, int arg2); static void Main() { IntPtr intptr = new IntPtr(123456789); MyFunction(intptr, 42); }In this example, we define an external function in a DLL that takes an IntPtr and an integer as arguments. We create a new IntPtr with a specific value and call the function with the two arguments. The IntPtr struct is part of the System namespace in the .NET Framework and does not require any additional packages or libraries.