About List

Hi, I am new to C#.
static List<string> list = new List<string>(5);
list.add("a");
list.add("b");
list.add("c");

Now I wish to get element at index 2(which is c), how do I specify this in c#?
LVL 9
william007Asked:
Who is Participating?
 
monarch_ilhanConnect With a Mentor Commented:
MessageBox.Show(list[2]);
0
 
lucky_jamesCommented:
to insert at index 2:
list.Insert(2, "Compsognathus");

to get the element from index 2:
list[2].ToString();


Hope it helps.
0
All Courses

From novice to tech pro — start learning today.