I have to take user input and retype it into alternate capital letters. I took a string and converted it to a char array, and I'm trying to do this using the rest of the position in the array.
The problematic lines are the y = letter.ToUpper () and y = letter.ToLower () lines, which give me the error "No overload for the" ToUpper "/" ToLower "method takes 0 arguments. I'm not sure why I get an error even after looking examples of other people.
static void Main(string[] args)
{
Console.Write("Enter anything: ");
String x = Console.ReadLine();
char[] array = x.ToCharArray();
for(int i = 0; i<array.Length; i++)
{
char letter = array[i];
char y;
if(i % 2 == 0)
{
y = letter.ToUpper();
Console.Write(y);
}
else if(i % 2 == 1)
{
y = letter.ToLower();
Console.Write(y);
}
}
}
user4840466
source
share