using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
static void Main()
{
string s = "Would you like to know more? (Explore and learn)";
int n = 2;
string result = MoveNthWordToEndOfString(s, n);
Console.WriteLine(result);
}
public static string MoveNthWordToEndOfString(string input, int n)
{
if (string.IsNullOrWhiteSpace(input))
return input;
List<string> parts = input
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.ToList();
if (n < 0 || n >= parts.Count)
throw new ArgumentOutOfRangeException(nameof(n), "Index is out of range.");
string word = parts[n];
parts.RemoveAt(n);
parts.Add(word);
return string.Join(" ", parts);
}
}
/*
run:
Would you to know more? (Explore and learn) like
*/