6.索引器 字符串作为索引号 public class Demo { private Hashtable name = new Hashtable(); public string this[string index] { set { name.Add(index, value); } get { return name[index].ToString(); } } } public class Test { public static void Main(string[] args) {
5.索引器 数字作为索引号 public class IndexerClass { private string[] name = new string[2]; public string this[int index] { get { if (index < 2) { return name[index]; } return null; } set { if (index < 2) { name[index] = value; } } } } public class Test { pu
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ