日期:2014-05-17 浏览次数:20961 次
var obj = new { Name = "aa", ID = 1, Age = 22 };
string[] props = obj.GetType().GetProperties().Select(x => x.Name).ToArray();
string[] values = obj.GetType().GetProperties().Select(x => x.GetValue(obj, null).ToString()).ToArray();
foreach (var item in props.Zip(values, (x, y) => x + ":" + y))
{
Console.WriteLine(item);
}