1)on C bool and string can never be implicitly converted
5)
string inString, outString="";
int i;
Console.WriteLine("Please enter a string:");
inString = Console.ReadLine();
char[] inChars = inString.ToCharArray();
for (i = inChars.Length - 1; i >= 0; i--)
{
outString=outString + inChars[i];
}
Console.WriteLine("'{0}' reversed is '{1}'", inString, outString);
That is if you wanted to do it in a for loop, I believe that works.
7)
string inString, outString="";
Console.WriteLine("Please enter a string:");
inString = Console.ReadLine();
string[] words;
words = inString.Split();
foreach (string word in words)
{
outString = outString + "\"" + word + "\" ";
}
Console.WriteLine("Everything with quotes: {0}", outString);
I think this works too, and slightly shorter.
Everything else looks great. Thanks for posting this. Because for some reason when I tried to do these questions the day after I read it, I was drawing a blank. Your answer 5 really helped jog my memory ;)
From what my friends tell me the reason you need outString="". Is that c# likes it if you can define your variables, so that you can manipulate it even if it is a blank space. Before in languages like
VB you didn't have to, and it cause alot of crashing problems. Btw this is what someone told me off hand so it might not be 100% right.