4
Reply

How can you read an integer value from the keyword when the application is runtime?example?

Krishna Rajput Singh

Krishna Rajput Singh

Jul 16, 2014
6.6k
1

    using Console.Readline()

    Rahul Prajapat
    June 01, 2015
    1

    using Console.Readline()

    We can also use int.Parse to conver string into integar. Example: String abc="500"; int num=int.Parse(abc); Console.writeline(num);It will also give output 500

    Piyush chhabra
    April 20, 2015
    0

    You can use the console.ReadLine()method to read a value an integer from the keyboard, but console.ReadLine() method returns String value.Therefore, if you want to read an integer value , you need to convert the value returned by console.ReadLine() into an integer value. Syntax: int value=convert.ToInt32(console.ReadLine()); using System; using System.Collections.Generic; using System.Text;namespace ConsoleApplication4 {class Program{public void f1(){int score;System.Console.WriteLine("Enter the Score");score = Convert.ToInt32(Console.ReadLine()); // convert here intger valueswitch (score){case 100:Console.WriteLine("Century");break;case 200:Console.WriteLine("Double Century");break;default:Console.WriteLine("Invalid case");}}static void Main(string[] args){Program pro = new Program();pro.f1();Console.ReadLine();}} }