-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsole.cs
38 lines (36 loc) · 897 Bytes
/
Console.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
namespace Util
{
public static class ExtensionMethods
{
public static int toInt(this string value)
{
return int.Parse(value);
}
}
public class Console
{
static public string Ask(string question)
{
System.Console.Write(question);
return System.Console.ReadLine();
}
static public string Ask(int question)
{
System.Console.Write(question);
return System.Console.ReadLine();
}
static public int AskInt(string question)
{
try
{
System.Console.Write(question);
return System.Console.ReadLine().toInt();
}
catch (Exception)
{
throw new FormatException("Input was not a number.");
}
}
}
}