9d4eab5c7e70d78cc3a421be199562938d1f4161
[reactos.git] / irc / TechBot / TechBot.Library / NumberParser.cs
1 using System;
2 using System.Globalization;
3
4 namespace TechBot.Library
5 {
6 public class NumberParser
7 {
8 public bool Error = false;
9
10 public long Parse(string s)
11 {
12 try
13 {
14 Error = false;
15 if (s.StartsWith("0x"))
16 return Int64.Parse(s.Substring(2),
17 NumberStyles.HexNumber);
18 else
19 return Int64.Parse(s);
20 }
21 catch (FormatException)
22 {
23 Error = true;
24 }
25 catch (OverflowException)
26 {
27 Error = true;
28 }
29 return -1;
30 }
31 }
32 }