主题:索引下标
索引下标:
一个索引与属性除了不使用属性名来引用类成员而是用一个方括号中的数字来匿名引用(就象用数组下标一样)以外是相似的.
public class ListBox: Control { private string[] items; public string this[int index] { get { return items[index]; } set { items[index] = value; Repaint(); } } }
可以用一个循环器来匿名引用字符串内部数组成员,就象下面这样:
ListBox listBox = ...; listBox[0] = "hello"; Console.WriteLine(listBox[0]);
[em2][em3][em9]
(⊙v⊙)嗯!就这样吧!
详细了解请转载到:
[url=http://www.ithuhang.com ]http://www.ithuhang.com [/url]