关于 UtilConvert Bug 返回
很久了 ! 很久了 ! 麻烦作者大人修复一下 ObjToInt的Bug行不行?
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static int ObjToInt2(this object thisValue)
{
int reval = 0;
if (thisValue == null) return 0;
if (thisValue is Enum)
{
return (int)thisValue;
}
if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return reval;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static int ObjToInt2(this object thisValue, int errorValue)
{
int reval = 0;
if (thisValue == null) return 0;
if (thisValue is Enum)
{
return (int)thisValue;
}
if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
多一个判断Enum行不行 ? 不然每次都改挺麻烦的. 修复一下 ?
热忱回答(1)
-
fate stay night VIP0
2020/4/17后续会更新
0 回复