Инверсия регистра - C#
Формулировка задачи:
Из больших букв - маленькие
Из маленьких - большие
Пример:
Привет, Андрей
пРИВЕТ, аНДРЕЙ
Инверсия регистра мне нужна
Решение задачи: «Инверсия регистра»
textual
Листинг программы
string input = "<place_your_string_here>";
char[] inversedChars = new char[input.Length];
for (int index = 0; index < input.Length; ++index)
{
char current = input[index];
if (char.IsLetter(current))
{
inversedChars[index] = char.IsUpper(current) ? char.ToLower(current) : char.ToUpper(current);
}
else inversedChars[index] = current;
}
string inversedString = new string(inversedChars);