35 lines
885 B
C#
35 lines
885 B
C#
namespace WinFormDiApp.BL.Helpers;
|
|
|
|
public static class Extensions
|
|
{
|
|
public static bool IsNumeric(this string value)
|
|
{
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
if (value.All(char.IsDigit)) return true;
|
|
else return false;
|
|
}
|
|
else return false;
|
|
}
|
|
|
|
public static bool IsDate(this string value) {
|
|
if (!string.IsNullOrEmpty(value) && value.Length<20)
|
|
{
|
|
if (DateTime.TryParse(value, out DateTime date))
|
|
{
|
|
return true;
|
|
}
|
|
else return false;
|
|
}
|
|
else return false;
|
|
}
|
|
|
|
public static string adjustRight(this string value) {
|
|
if (!string.IsNullOrEmpty(value) && value.Length < 20)
|
|
{
|
|
return " ".Substring(0, 20 - value.Length)+value;
|
|
}
|
|
else return value;
|
|
}
|
|
}
|