日期:2014-05-18  浏览次数:20675 次

C#中的Indexer怎么用??
C#中的Indexer怎么用??
比如说有一组texbox
怎样才能把这些textbox构建成数组
来调用textbox[i]?
请给出代码


------解决方案--------------------
public class TextBoxes
{
string[] m_Values;
public TextBoxes(params string[] values)
{
m_Values = new string[values.length];
values.CopyTo(m_Values,0);
}
 
public int this[string value]
{
get
{
return Array,IndexOf(m_Values,value);
}
}

public string this[int index]
{
get{ return m_Values[index];}
set{ m_Values[index] = value;}
}
}


------解决方案--------------------
TextBox[] t=new TextBox[10];
t[0]=new TextBox();