Unsafe C# Tutorial

using System;
using System.Globalization;
public class MainClass{
  public static void SafeSwap(ref int i, ref int j)
  {
    int temp = i;
    i = j;
    j = temp;
  }
  static void Main(string[] args)
  {
    int i = 10, j = 20;
    
    Console.WriteLine("Values before safe swap: i = {0}, j = {1}", i, j);
    SafeSwap(ref i, ref j);
    Console.WriteLine("Values after safe swap: i = {0}, j = {1}", i, j);
  }
}
Values before safe swap: i = 10, j = 20
Values after safe swap: i = 20, j = 10