new IntPtr
using System;
using System.IO;
using System.Reflection;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
public class MainClass
{
public unsafe static void Main()
{
int a = 10;
Console.WriteLine("a is {0} ({0:X})", a);
IntPtr ip = new IntPtr(&a);
byte* pTarget = (byte*)ip.ToPointer() + 1;
*pTarget = 2;
Console.WriteLine("a is {0} ({0:X})", a);
}
}
Related examples in the same category