Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m trying to make a array of labels how can i do this.
thanx in advance
Posted

C#
Label[] labels = new Label[numLabels];
Label lbl = new Label();
labels[0] = lbl;


or use a List<Label>

C#
List<Label> labels = new List<Label>();
Label lbl = new Label();
labels.Add(lbl);
 
Share this answer
 
v3
Comments
Amir Mahfoozi 21-Nov-11 8:30am    
+5 I prefer List<Label>
BobJanova 21-Nov-11 8:42am    
Me too.

To the original questioner: remember that you still need to add those labels to a visible container control if you want them to be useful for anything.
LanFanNinja 21-Nov-11 10:45am    
Thank You
Himu from Orissa 21-Nov-11 9:00am    
thanx it works i m new dats why i dot know many things
LanFanNinja 21-Nov-11 10:46am    
You're welcome.
Please try this.

C#
Label[] lbl = new Label[3];
            lbl[0] = new Label();
            lbl[0].Text = "abc";
            lbl[1] = new Label();
            lbl[1].Text = "def";
            lbl[2] = new Label();
            lbl[2].Text = "pqrs";
 
Share this answer
 
Comments
Himu from Orissa 21-Nov-11 9:00am    
thanx it works i m new dats why i dot know many things
very useful I was looking for it for so long till I saw your post! very very useful thank you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900