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;
            }
        }
    }

 

posted @ 2014-03-04 16:58  fang_beny  阅读(166)  评论(0编辑  收藏  举报