IList裡存了N行類似以下數據
{a=1,b=2,c=3,d=4}
我要使用每一行中每一列的值,如何遍歷??
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<object> list = new List<object>()
{
new {a=1,b=2,c=3,d=4},
new {a=11,b=12,c=13,d=14},
new {a=21,b=22,c=23,d=24},
new {a=31,b=32,c=33,d=34}
};
foreach (object obj in list)
{
foreach (object v in obj.GetType().GetProperties().Select(x => x.GetValue(obj, null)))
{
Console.Write(v + "\t");
}
Console.WriteLine();
}
}
}
}