C#_ Char to String

I am learning to use methods in C# . In this example I am trying to convert Char to String but it is giving me error. I do not understand where I am going wrong.

  private void RunScript(object x, object y, ref object A)
  {
    Print(ReverseString());
  }

  // <Custom additional code> 
  private static string ReverseString()
  {
    string message = "Hello World!";
    char[] messageArray = message.ToCharArray();
    Array.Reverse(messageArray);
    
    foreach(char item in messageArray)
    {
      string iString = item.ToString();
      return iString;
    }
  }

This is the error its giving…
Error (CS0161): ‘Script_Instance.ReverseString()’: not all code paths return a value (line 76)

Thanks,

That is because you are not returning anything at the end of the function. You do have a return inside a foreach loop (which in itself doesn’t make much sense, since it will only ever do one character if there is any), but if there are no characters there won’t be any loop, thus no return at the end.

The internet already has many, many, many answers to your actual problem, converting char array to string.

https://duckduckgo.com/?q=c%23+string+from+char+array