1

Im trying to take a string of characters check if any of the charachters in that string are lowercased, if that is the case I want to change them, but when im trying to use Char.ToLower() nothing happens.

Console.Clear();

string rightWord = "Arose";
//making all letters into small letters

//making a array of the right word
char[] rightWordArray = rightWord.ToCharArray();

for (int i = 0; i < rightWord.Length; i++)
{
    if (char.IsUpper(rightWordArray[i]))
    {
        char.ToLower(rightWordArray[i]);
    }
}

//writing out all chars in rightWordArray
foreach (var item in rightWordArray)
{
Console.WriteLine(item);
}



I have tried String.ToLower too but it doesent work.

Darre
  • 21
  • 2
  • 2
    `char.ToLower(rightWordArray[i]);` returns the input character converted to lower case. It does not modify the input in place – UnholySheep Nov 13 '22 at 21:02
  • 1
    Thank you, this line workt, rightWordArray[i] = char.ToLower(rightWord[i]); – Darre Nov 13 '22 at 21:05

1 Answers1

1

Per UnholySheep's comment:

char.ToLower(rightWordArray[i]); returns the input character converted to lower case. It does not modify the input in place

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Darre
  • 21
  • 2