25 lines
531 B
C#
25 lines
531 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace ExtensionMethods
|
|
{
|
|
public static class ObjectExtension
|
|
{
|
|
public static string ToSafeTurnString(this object obj)
|
|
{
|
|
if (obj == null)
|
|
return string.Empty;
|
|
|
|
return obj.ToString();
|
|
}
|
|
|
|
public static bool ToBool(this object obj)
|
|
{
|
|
bool.TryParse(obj.ToSafeTurnString(), out bool resultVal);
|
|
return resultVal;
|
|
}
|
|
}
|
|
}
|