You can create your own array of labels and initialize it in Form_Load event
handler, or right in the constructor after all the labels are created.
Something like:
private Label[] m_arrLabels;
private void Form_Load( object sender, EventArgs e )
{
m_arrLabels = new Label[3] { Label1, Label2, Label3 };
for( int i = 0; i < m_arrLabels.Length; i ++ )
m_arrLabels[i].Text = "label " + i;
}
"Jim McGivney" <mc****@no-spam.sbcglobal.netwrote in message
news:uW**************@TK2MSFTNGP03.phx.gbl...
In VB6 I could form an array of labels and reference them by index number.
In a C# ASP.net 2 application I need to reference Label33 through Label64
programmatically. I'd like to use a for loop
for (i = 33; i < 65; i += 1)
Any suggestions on how to accomplish this would be appreciated. Code
samples are welcomed. I'd like the correct syntax.
Thanks in advance for your help,
Jim