using System.Collections.Generic;
using System.Diagnostics;
public string Name { get; set; }
public int Age { get; set; }
public static void Main()
List<Person> personList = new List<Person>();
personList.Add(new Person(){Name = "aaa", Age = 10});
personList.Add(new Person(){Name = "bbb", Age = 5});
for(int i = 0; i< 10; i++)
personList.AddRange(personList);
Dictionary<string, PropertyInfo> propDict = typeof(Person).GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(p => p.CanRead && !p.GetIndexParameters().Any()).AsEnumerable().ToDictionary(x => x.Name, x => x);
int count = personList.Count;
Stopwatch sw = new Stopwatch();
foreach(var prop in propDict)
var tempArray = personList.Select(x => prop.Value.GetValue(x)).ToArray();
Console.WriteLine(tempArray.GetType().Name);
Console.WriteLine("Spend" + sw.ElapsedMilliseconds + "us");
foreach(var prop in propDict)
var tempArray = personList.Select(x => Convert.ChangeType(prop.Value.GetValue(x), prop.Value.PropertyType)).ToArray();
Console.WriteLine(tempArray.GetType().Name);
Console.WriteLine("Spend" + sw.ElapsedMilliseconds + "us");
foreach(var prop in propDict)
var tempArray = personList.Select(x => prop.Value.GetValue(x)).ToArray();
Array stronglyTypeArray = Array.CreateInstance(prop.Value.PropertyType, count);
Array.Copy(tempArray, stronglyTypeArray, count);
Console.WriteLine(stronglyTypeArray.GetType().Name);
Console.WriteLine("Spend" + sw.ElapsedMilliseconds + "us");
foreach(var prop in propDict)
if(prop.Value.PropertyType == typeof(System.String))
tempArray = personList.Select(x => prop.Value.GetValue(x).ToString()).ToArray();
else if(prop.Value.PropertyType == typeof(System.Boolean))
tempArray = personList.Select(x => (bool)prop.Value.GetValue(x)).ToArray();
else if(prop.Value.PropertyType == typeof(System.Byte))
tempArray = personList.Select(x => (byte)prop.Value.GetValue(x)).ToArray();
else if(prop.Value.PropertyType == typeof(System.Char))
tempArray = personList.Select(x => (char)prop.Value.GetValue(x)).ToArray();
else if(prop.Value.PropertyType == typeof(System.Decimal))
tempArray = personList.Select(x => (decimal)prop.Value.GetValue(x)).ToArray();
else if(prop.Value.PropertyType == typeof(System.Double))
tempArray = personList.Select(x => (double)prop.Value.GetValue(x)).ToArray();
else if(prop.Value.PropertyType == typeof(System.Int16))
tempArray = personList.Select(x => (short)prop.Value.GetValue(x)).ToArray();
else if(prop.Value.PropertyType == typeof(System.Int32))
tempArray = personList.Select(x => (int)prop.Value.GetValue(x)).ToArray();
else if(prop.Value.PropertyType == typeof(System.Int64))
tempArray = personList.Select(x => (long)prop.Value.GetValue(x)).ToArray();
else if(prop.Value.PropertyType == typeof(System.Single))
tempArray = personList.Select(x => (float)prop.Value.GetValue(x)).ToArray();
tempArray = personList.Select(x => prop.Value.GetValue(x)).ToArray();
Console.WriteLine(tempArray.GetType().Name);
Console.WriteLine("Spend" + sw.ElapsedMilliseconds + "us");