2013-03-02 19:32:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2014-12-02 06:39:27 +00:00
|
|
|
|
namespace NzbDrone.Common.Extensions
|
2013-03-02 19:32:55 +00:00
|
|
|
|
{
|
2014-12-02 06:26:25 +00:00
|
|
|
|
public static class TryParseExtensions
|
2013-03-02 19:32:55 +00:00
|
|
|
|
{
|
|
|
|
|
public static Nullable<int> ParseInt32(this string source)
|
|
|
|
|
{
|
|
|
|
|
Int32 result = 0;
|
|
|
|
|
|
|
|
|
|
if (Int32.TryParse(source, out result))
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2013-12-12 00:41:58 +00:00
|
|
|
|
|
|
|
|
|
public static Nullable<long> ParseInt64(this string source)
|
|
|
|
|
{
|
|
|
|
|
Int64 result = 0;
|
|
|
|
|
|
|
|
|
|
if (Int64.TryParse(source, out result))
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2013-03-02 19:32:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|