对List泛类。修改值的一个简单扩展

 public static void EditValue<T>(this IList<T> array, Func<T, bool> where, T newobjs)
        {
            Type t = typeof(T);
            if (array.Any(where))
            {
                foreach (T item in array)
                {
                    if (where(item))
                    {
                        var allpro = t.GetProperties();
                        foreach (PropertyInfo pi in t.GetProperties())
                        {
                            pi.SetValue(item, pi.GetValue(newobjs, null), null);
                            Logger.Default.Info(pi.GetValue(item, null).ToString());
                        }

                    }
                }
            }
            else
            {
                array.Add(newobjs);
            }
           
        }

  

原文地址:https://www.cnblogs.com/jizhongfong/p/4499938.html