Method Swap
Swap<T>(ref T, ref T)
Exchanges the values of two variables of the same type.
public static void Swap<T>(ref T a, ref T b)
Parameters
aTA reference to the first variable whose value will be exchanged.
bTA reference to the second variable whose value will be exchanged.
Type Parameters
TThe type of the variables to swap.
Remarks
Both parameters must be of the same type. This method is useful for swapping values in place without requiring an additional temporary variable outside the method.