mirror of
https://github.com/reactos/reactos.git
synced 2025-01-02 20:43:18 +00:00
9dab4509fa
svn path=/trunk/; revision=13064
32 lines
524 B
C#
32 lines
524 B
C#
using System;
|
|
using System.Globalization;
|
|
|
|
namespace TechBot.Library
|
|
{
|
|
public class NumberParser
|
|
{
|
|
public bool Error = false;
|
|
|
|
public long Parse(string s)
|
|
{
|
|
try
|
|
{
|
|
Error = false;
|
|
if (s.StartsWith("0x"))
|
|
return Int64.Parse(s.Substring(2),
|
|
NumberStyles.HexNumber);
|
|
else
|
|
return Int64.Parse(s);
|
|
}
|
|
catch (FormatException)
|
|
{
|
|
Error = true;
|
|
}
|
|
catch (OverflowException)
|
|
{
|
|
Error = true;
|
|
}
|
|
return -1;
|
|
}
|
|
}
|
|
}
|