0

how can i get input from user and use logical operators with it

like if i want the user to add his age and then use && operator and > operator how can i do that

10th Apr 2017, 5:42 PM
Upendra Juneja
Upendra Juneja - avatar
1 Resposta
+ 1
This is just a sample code. use Console.ReadLine(); to read from user // Read user input string input = Console.ReadLine(); int age = 0; // Convert string to int bool result = int.TryParse(input ,out age); if(result && age > 0){ // Ur logic goes here if(age > 13 && age < 18) { //some code } }else{ Console.WriteLine("Please Enter valid Age"); }
11th Apr 2017, 4:30 AM
Eranga
Eranga - avatar