public void tampilkanHasilSwap() { PersonSwap a = new PersonSwap(); a.i = 10; a.s = "Person of A"; PersonSwap b = new PersonSwap(); b.i = 20; b.s = "Person of B"; this.swapObjectReference(a, b); Swap <PersonSwap>(ref a, ref b); }
public void swapObjectReference(PersonSwap a, PersonSwap b) { PersonSwap temp; temp = a; a = b; b = temp; /** * Output * * A is : Person of B * B is : person of A **/ Console.WriteLine("A is :" + a.s + "\n& B is :" + b.s); }