mirror of
https://github.com/reactos/reactos.git
synced 2025-06-18 18:35:23 +00:00
Import TechBot
svn path=/trunk/; revision=13064
This commit is contained in:
parent
568b27baeb
commit
9dab4509fa
94 changed files with 24386 additions and 0 deletions
32
irc/TechBot/TechBot.Library/NumberParser.cs
Normal file
32
irc/TechBot/TechBot.Library/NumberParser.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue