public static bool Compare(Object objOld, Object objNew)
{
try
{
Type type = objOld.GetType();
PropertyInfo[] infos = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
for (int j = 0; j < infos.Length; j++)
{
if (infos[j].PropertyType.Equals(typeof(string)))
{
if (!infos[j].GetValue(objOld, null).ToString().Trim().Equals(infos[j].GetValue(objNew, null).ToString().Trim()))
{
return false;
}
}
else
{
if (!infos[j].GetValue(objOld, null).Equals(infos[j].GetValue(objNew, null)))
{
return false;
}
}
}
return true;
}
catch (Exception ex)
{
StackFrame fr = new StackFrame(true);
CMS.GCL.Log.WriteLine(fr.GetMethod().ReflectedType.FullName + "_" + fr.GetMethod().Name, ex.Message, CMS.GCL.LogLevel.Error);
return false;
}
}
两个objec比较
最新推荐文章于 2021-11-09 12:42:30 发布