February 16th, 2004, 07:26 AM
C# user input
Ok, this is probably very simple! but how do you get user input from a console window. I've been looking though learning C# and i just cant find anything at all. I was thinking something to do with System.Console or System.IO but .
February 16th, 2004, 10:37 AM
February 17th, 2004, 07:02 AM
Thanks Yogi, works perfectly! I'll give the tutorials a good reading a little latter
April 2nd, 2008, 10:53 AM
Ok, that was really helpful, but what if i wanted there to be an int value or a number. What is the code for that?
April 2nd, 2008, 11:09 AM
Always read from the console as a string. Then use Typname.Parse() or Typename.TryParse() to convert that to your desired type. For example, if you want an integer it would be Integer.Parse. A Decimal would be Decimal.Parse. Same for a Datetime. You can also use Convert.ToTypename() for more exotic types.