[Solved] trouble with swapping firstInt, middleInt, and lastInt [closed]


This is the problem:

private static void Swap(ref int first, ref int middle, ref int last);

   int temp;
    temp = firstInt;
    firstInt = lastInt;
    lastInt = temp;

   }

You have a ; after the parameter list of your method Swap, when it should be a { (curly brace):

private static void Swap(ref int first, ref int middle, ref int last)
{

    int temp;
    temp = firstInt;
    firstInt = lastInt;
    lastInt = temp;
}

Your code generates a “Type or namespace definition, or end-of-file expected.” error.

EDIT

As others have pointed out, you also have the wrong variables name – it should be first, middle and last, so you’re whole method would be:

private static void Swap(ref int first, ref int middle, ref int last)
{

    int temp;
    temp = first;
    first = last;
    last = temp;
}

solved trouble with swapping firstInt, middleInt, and lastInt [closed]