【发布时间】:2014-08-07 15:22:46
【问题描述】:
我为每种音乐类型形成了一个数组列表,例如我将展示乡村音乐:
public class CountryItemList
{
ArrayList CountryItems = new ArrayList();
protected void CountryBuy1_Click(object sender, ImageClickEventArgs e)
{
CountryItems.Add("Johnny Cash - I Walk The Line - $9");
}
protected void CountryBuy2_Click(object sender, ImageClickEventArgs e)
{
CountryItems.Add("Carrie Underwood - Blown Away - $9");
}
protected void CountryBuy3_Click(object sender, ImageClickEventArgs e)
{
CountryItems.Add("Keith Urban - The Story So Far - $9");
}
protected void CountryBuy5_Click(object sender, ImageClickEventArgs e)
{
CountryItems.Add("Taylor Swift - Red - $11");
}
protected void CountryBuy6_Click(object sender, ImageClickEventArgs e)
{
CountryItems.Add("Willie Nelson - Legend - $9");
}
}
}
对于单击的每个购买按钮,所选专辑将添加到数组列表中,从那时起,我希望将数组列表带入会话并将其带到“购物车页面”上的列表框。我在获取数组列表并将其转换为会话以延续到下一页时遇到问题
【问题讨论】:
-
对于初学者,您有什么理由使用 ArrayList 而不是通用集合之一?
-
您应该将
CountryItems设为List<string>而不是ArrayList。
标签: c# asp.net arrays session arraylist