• Advertisement
Sign in to follow this  

[.net] How to get input of just for an integer? (C#)

This topic is 4949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm disliking Console.Read(LINE)() function right now. I'm in the process of making a Tic Tac Toe clone just so I can remember some of the stuff I have learned using C# and it's just being a bitch about every thing. Here's the C/C++ equivilent of what I'd like to do:
void DoTurn()
{
  cout << Turn << "'s turn!";
  int move;
  cin >> move
  // do some error checking...
  if (GameBoard[move])...
}
But NOOooooooo, C# only returns a string with the ReadLine() function and boxing has no effect whatsoever.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Something like that:
int moves = int.Parse( Console.ReadLine() );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement