匿名对象解析
class Program
{
static void Main(string[] args)
{
List<object> obj = new List<object>();
obj.Add(new { aa=1,bb=1});
obj.Add(new { aa = 1, bb = 2 });
var objs = obj.Select(t => t.Cast(new { aa = 0, bb = 0 })).ToList();
Console.ReadKey();
}
}
static class Extensions
{
public static T Cast<T>(this object obj, T sample)
{
return (T)obj;
}
}

浙公网安备 33010602011771号