object缺省转义成字符串输出
2017-01-30 19:04:15 访问(1535) 赞(0) 踩(0)
/// <summary>
/// object缺省转义成字符串输出
/// </summary>
/// <param name="theValue"></param>
/// <returns></returns>
public string ObjectToString(object theValue)
{
if (theValue == null)
return "";
Type t = theValue.GetType();
if (t == typeDateTime || t == typeDateTimeNull)
{
DateTime dtValue = (DateTime)theValue;
if (dtValue == dtValue.Date)
{
return dtValue.ToString("yyyy-MM-dd");
}
else
{
if (DateTimeFormatShowSecond)
return dtValue.ToString("yyyy-MM-dd HH:mm:ss");
else
return dtValue.ToString("yyyy-MM-dd HH:mm");
}
}
if (t == typeBoolean || t == typeBooleanNull)
{
bool boolValue = (bool)theValue;
if (boolValue)
return "1";
else
return "0";
}
if (t == typeString)
{
return theValue.ToString();
}
return theValue.ToString();
}
标签:
object缺省转义成字符串输出 


上一条:
下一条:
相关评论
发表评论