I have to swap the characters in a string before sending said string to a device to show the information sent through a LCD, the method I developed is as follows:private string StringSwap(string stringToSwap){    if ((stringToSwap.Length % 2).Equals(1))    {        stringToSwap +=  ;    }    char[] array = stringToSwap.ToCharArray();    for (int i = 0; i < array.Length; i += 2)    {        char temp = array[i];        array[i] = array[i + 1];        array[i + 1] = temp;    }    return new string(array);}I want to know if there are any implementations that do this already (I feel like I am reinventing the wheel here) or, in case there is not, know how to optimize and make this code more resilient, while also making it more readable.Also, should I make this an extension for the string class instead of a method?
Swapping characters pairs in a string
c#;strings;array
Here it as an extension. It helps to properly name all the steps:static class StringSwap{    public static string Swap(this string text) =>        new string(text            ?.PadToEvenLength()            ?.SwapOddEvenChars()            ?.ToArray());    static string PadToEvenLength(this string text) =>        text.Length.IsOdd() ? text + ' ' : text;    static IEnumerable<char> SwapOddEvenChars(this string text) =>        text.Select((c, i) => i.IsOdd() ? text[i - 1] : text[i + 1]);    static bool IsOdd(this int number) =>         number % 2 == 1;        }