摘要: class IndexerExample { public Hashtable list = new Hashtable(); public int this[string name] { get { return (int) list[name]; } set { list[name] = value; } } } //class IndexerExample //{ // public string[] stringList = new string[10]; // public string this[int index] // { // get { return stringList[index]; } // set { stringList[index] = value.ToString(); } // } //} 阅读全文
posted @ 2007-10-22 15:42 范文轩 阅读(133) 评论(0) 推荐(0) 编辑
摘要: public class Student { public string name; public int id; public int age=22; //set中的判断 public int Id { get { return id; } set { if (value id = value; else id = 100; } } //get后的计算 public string Name { get { return "Hello "+name; } set { name = value; } } 阅读全文
posted @ 2007-10-22 14:56 范文轩 阅读(523) 评论(1) 推荐(0) 编辑