using System;
using System.Globalization;
public class MainClass{
public static void SomeUnsafeCode()
{
unsafe
{
int myInt;
int* ptrToMyInt = &myInt;
// Assign value of myInt using pointer.
*ptrToMyInt = 123;
// print out address.
Console.WriteLine("Value of myInt {0}", myInt);
Console.WriteLine("Address of myInt {0:X}", (int)ptrToMyInt);
}
}
static void Main(string[] args)
{
SomeUnsafeCode();
}
}
|