I have something like this for you:
internal class Program
{
static void Main(string[] args)
{
// on this String we want make the changes
String Given= "Rubbish!";
//here we calл the method
Console.WriteLine(SwapTheDigits(Given));
// this only to prevent the console from closing
Console.ReadLine();
}
public static String SwapTheDigits(String given)
{
// here we declare the middle part of the string
String MiddlePart = "";
if (given == null)
{
// if the user is comming up with the empty string
// the error will be thrown
throw new ArgumentNullException("String can't be empty");
}
else
{
// and here is basically the whole "magic"
// You save the first digit of String Array into the First variable
// thw last into the last one
char First = given[0];
char Last = given[given.Length - 1];
// there are several overloads of the substring method
// here I'm using what fits the best for this task, to cut the first and the last (two) digits.
MiddlePart = given.Substring(1,given.Length - 2);
// and here we return the string with swaped digits.
return Last + MiddlePart + First;
}
}
}
I hope this helps. There are, of course, many more solutions out there. Even better then mine. As I am a beginner myself, this is one of my first attempts. For the same reason i'm not sure if my explanation helps you. You always welcome to ask, if you need more suport.
Thank you @Jeremy Caney for guiding.