In one of my web application page, I have a C# code as follows. How do I get the first element in the string array inside the arraylist?
Code
protected void Button3_Click(object sender, EventArgs e)
{
//Array test[9] = new Array();
ArrayList list = new ArrayList();
list.Add(new string[] { "1", "Test1", "20", "30" });
list.Add(new string[] { "2", "Test2", "5", "30" });
list.Add(new string[] { "3", "Test3", "10", "30" });
list.Add(new string[] { "4", "Test4", "20", "30" });
list.Add(new string[] { "5", "Test5", "0", "30" });
list.Add(new string[] { "6", "Test6", "15", "30" });
list.Add(new string[] { "7", "Test7", "10", "30" });
list.Add(new string[] { "8", "Test8", "20", "30" });
list.Add(new string[] { "9", "Test9", "30", "30" });
LabelMessages.Text = "Number of Items: " + list.Count + " Item 1 record 1: " + list[1];
}
Expected Output
Number of Items: 9 Item 1 record 1: 1
Current Output (which is not what I want)
Number of Items: 9 Item 1 record 1: System.String[]
So, suppose that the following code:
list.Add(new string[] { "1", "Test1", "20", "30" });
is change to:
list.Add(new string[] { "Test1", "20", "30" });
then the expected output should be:
Number of Items: 9 Item 1 record 1: Test1