So, I'm starting C# in class. *Removed*
I'm trying to make a simple console application that asks the user 'do you like cheese?' and if the user types 'yes' it says 'Good, I like cheese too', and if the user types 'no', it continues and asks 'why not?'. Useless, but I usually do this kind of crap to learn the basics.
So far, I have:
public class SampleClass
public static void Main()
// Write hello world to the console
System.Console.WriteLine("What is your name?");
string Name = System.Console.ReadLine();
System.Console.WriteLine("Hello " + Name + "!");
System.Console.WriteLine("Do you like cheese?");
string Answer = System.Console.ReadLine();
--More questions here, like what kind of cheese and such
--"What did you say? (Prompt the previous question)
System.Console.WriteLine("Press any key to exit the application");
} // End of Main function (program statup)
} // End of SampleClass
} // End of SampleNamespace
That's all fine and dandy, except I have no idea how to do the part commented out. That styling of (?) code would work in PHP, but it doesn't in C#. I get errors like 'too many characters in character literal', pointing to the 'case's.
Also, is there a way to restrict the user from only choosing "yes" or "no"?
By the way, this isn't my homework or anything. I just hate learning at the speed of everybody else when I'm known in my classroom as the 'programmer' (oddly enough
must be the PHP). While the rest of my class 'learns' what variables are, I want to be doing something a little more advanced. I just don't like learning slowly
, I don't mean to sound arrogant or anything.