for (int idx = 0; idx < myarray.Count; idx++)
{
object item = myarray[idx];
}
如何透過reflection做到上述功能?方法如下:
int count = (int)myarray.GetType().GetProperty("Count").GetValue(myarray, null);
for (int idx = 0; idx < count; idx++)
{
object item = myarray.GetType().GetProperty("Item").GetValue(myarray, new object[] { idx }
);