这要看属性是一个真实的数组还是一个实现了Indexer的类:
1) 一个数组:
   public class MyClass {
       private int[] _myarray = ...;
       public int[] MyArray {
            get { return _myarray; }
            set { _myarray = value; }
       }
   }
   MyClass myObj = new MyClass();    ... 这种情况下:
   PropertyInfo pinfo = ...; //取的MyArray的属性
   int[] a = pinfo.GetValue(myObj, null);
   a[5] = 100;               //赋值

解决方案 »

  1.   

    2) 如果是indexer的话要麻烦一些
    例如Form.Controls属性,实际上是一个ControlCollection对象,实现indexer。Form frm = ...;
    PropertyInfo pi = ...; //取的Controls属性描述
    Object o = pi.GetValue(frm, null);
    MethodInfo[] mis = o.GetType().GetDefaultMembers();
    PropertyInfo pinfo = null;
    foreach(MethodInfo mi in mis) {
       if (mi.MemberType == MemberTypes.Property) {
         pinfo = (PropertyInfo)mi; break;
       } 
    }
    if (pinfo != null) {
       pinfo.SetValue(o, new TextBox(...), new object[1] { 5 } ); //赋值
    }