c# 中的索引

在一个类中定义 索引 参数写到【】 中

public class class1{

 

public string this[int index]
    {
        get { return index.ToString(); }
    }

 

}

在本类中这样调用

this[55].ToString()

如果在别的类中 先 创建此类的实例

 

class1 b=new class1();

b【55】

总结 :方便的调用

 

posted @ 2009-12-14 11:51  任飞儿  阅读(276)  评论(0编辑  收藏  举报