introductory-examples/io/i-demo.cs - Demonstrations of Console input in C#. | Lecture 2 - slide 16 : 43 Program 3 |
/* Right, Wrong */ using System; public class InputDemo { public static void Main(){ Console.Write("Input a single character: "); char ch = (char)Console.Read(); Console.WriteLine("Character read: {0}", ch); Console.ReadLine(); Console.Write("Input an integer: "); int i = int.Parse(Console.ReadLine()); Console.WriteLine("Integer read: {0}", i); Console.Write("Input a double: "); double d = double.Parse(Console.ReadLine()); Console.WriteLine("Double read: {0:f}", d); } }