Lily P.

asked • 10/30/20

Method code won't work for capitalization

Hi! I am doing a code for method that will capitalize every other word in an input, however my code below does not work and I can not find the reason. Can someone pls help?


static string ToMixed (string input)

{

string output = "";

for (int i = 0; i < input.Length; i++)

{

if(i %2 == 0)

{

output = output + input[i].ToLower();

}

else

{

output = output + input[i].ToUpper();

}

}

return output;

}

static void Main(string[] args)

{

Console.Write("Write a word: ");

string input = Console.ReadLine();

string result = ToMixed(input);

Console.WriteLine(result);

Console.ReadKey();

}



The only clue ive got is in error message: No overload for method 'ToUpper (and 'ToLower') takes 0 arguments. I dont know what they mean

Elise B.

tutor
Did you mean capitalize every other letter?
Report

10/30/20

Lily P.

Yes, oops now notice my typo
Report

10/31/20

1 Expert Answer

By:

Lily P.

Ooh thanks a lot!
Report

10/31/20

Elise B.

tutor
You're welcome!
Report

10/31/20

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.