Ui-Info-Suite/SDVModTest/Extensions/StringExtensions.cs

48 lines
1006 B
C#
Raw Normal View History

2017-07-20 11:51:05 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UIInfoSuite.Extensions
{
static class StringExtensions
{
public static Int32 SafeParseInt32(this String s)
{
Int32 result = 0;
if (!String.IsNullOrWhiteSpace(s))
{
Int32.TryParse(s, out result);
}
return result;
}
public static Int64 SafeParseInt64(this String s)
{
Int64 result = 0;
if (!String.IsNullOrWhiteSpace(s))
Int64.TryParse(s, out result);
return result;
}
2017-07-20 11:51:05 +08:00
public static bool SafeParseBool(this String s)
{
bool result = false;
if (!String.IsNullOrWhiteSpace(s))
{
Boolean.TryParse(s, out result);
}
return result;
}
}
}