Read int from console and convert string to int in CSharp
Description
The following code shows how to read int from console and convert string to int.
Example
//from ww w. j ava2s .c om
using System;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
Console.WriteLine("Enter an integer:");
int myInt = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Integer less than 10? {0}", myInt < 10);
Console.WriteLine("Integer between 0 and 5? {0}",
(0 <= myInt) && (myInt <= 5));
Console.WriteLine("Bitwise AND of Integer and 10 = {0}", myInt & 10);
}
}
The code above generates the following result.