C#索引器及示例

  public class IndexSeletor<T> where T:struct
    {
        private  List<T> _listObj;
        public IndexSeletor(List<T> listParm)
        {
            this._listObj = listParm;
        }
        public  T this[int index]
        {
            get {
                if (index >= 100)
                    return _listObj[index];
                else
                    return default(T);
            }
            set {
                if (index >= 100)
                    _listObj[index] =value;
            }
        }
    }
原文地址:https://www.cnblogs.com/fang-beny/p/3580709.html