using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CP.Common
{
///
/// 扩展编写
///
public static class Extension
{
///
/// 转换为Int32
///
///
///
public static int ToInt32(this object value)
{
return int.Parse(value.ToString());
}
///
/// 字符串是否是int32
///
///
///
public static bool IsInt32(this string value)
{
int i = 0;
if (int.TryParse(value, out i))
return true;
return false;
}
///
/// 转化为时间
///
///
///
public static DateTime ToDateTime(this string vlaue)
{
return DateTime.Parse(vlaue);
}
public static DateTime ToDateTime1(this string value)
{
var data = "";
for (int i = 0; i < value.Length; i++)
{
data += value[i];
if (i == 3 || i == 5)
{
data += "-";
}
}
return DateTime.Parse(data);
}
///
/// 转换为日期
///
///
///
public static DateTime ToDate(this string value)
{
return DateTime.Parse(value).ToString("yyyy-MM-dd").ToDateTime();
}
///
/// 字符串是否为空
///
///
///
public static bool IsEmpty(this string value)
{
if (string.IsNullOrEmpty(value))
return true;
return false;
}
}
}