Web アプリケーション ページの 1 つに、次のような C# コードがあります。arraylist 内の文字列配列の最初の要素を取得するにはどうすればよいですか?
コード
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];
}
期待される出力
Number of Items: 9 Item 1 record 1: 1
現在の出力(これは私が望むものではありません)
Number of Items: 9 Item 1 record 1: System.String[]
したがって、次のコードがあるとします。
list.Add(new string[] { "1", "Test1", "20", "30" });
は次のように変更されます:
list.Add(new string[] { "Test1", "20", "30" });
期待される出力は次のようになります。
Number of Items: 9 Item 1 record 1: Test1