SoFunction
Updated on 2025-03-07

C# Method of inverting arrays using custom algorithms

public static void ReverseArray<T>(this T[] inputArray)
{
  T temp = default(T);
  if (inputArray == null)
    throw new ArgumentNullException("inputArray is empty");
  if ( > 0)
  {
    for (int counter = 0; counter < ( / 2); counter++)
    {
      temp = inputArray[counter];
      inputArray[counter] = inputArray[ - counter - 1];
      inputArray[ - counter - 1] = temp;
    }
  }
  else
  {
    ("Reversal not needed");
  }
}