Checking if user input is an integer in c# -


this question has answer here:

so i'm making little text game, , need user enter integer when asks grid size. , if integer isn't entered want question asked again.

right have:

console.writeline("enter grid size."); int gridsize = int.parse(console.readline()); 

i need way check if input integer, , ask again if it's not. thanks

you can use tryparse:

var input = 0; if(int.tryparse(console.readline(), out input) { } 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -