public class YourClassCollection : CollectionBase
{
public YourClassCollection()
{
}
public void Add(YourClass item)
{
List.Add(item);
} public void Remove(int index)
{
if (index > Count - 1 || index < 0)
{
throw( new Exception(String.Format("&#892;&#638;&#1717;&#1322;λ:{0}", index)));
}
else
{
List.RemoveAt(index);
}
} public YourClass this[int index]
{
get
{
return (YourClass)List[index];
}
set
{
List[index] = value;
}
}
}

解决方案 »

  1.   

    把YourClass换成你的Collection类的成员类即可。
      

  2.   

    我的想法是这样:
    class MyItem
    {
    private SomeCollection values; //SomeCollection含有索引器属性
    public object Values[int indexer]
    {
    get {
    return values[indexer];
    }
             set {
                      values[indexer]=(SomeCollection)value;
              }
    }
    }
      

  3.   

    在get时可能有问题(是否要先转换成object?),欢迎拍砖
      

  4.   

    to qimini:这样写连编译都通不过,[ ]前好象必须是this
      

  5.   

    直接在外部赋值,如下:SomeCollection sc = new SomeCollection();
    sc[0] = "1";MyItem item = new MyItem();
    item.Values = sc;