
string[,] items = new string[100,4];
然后我收集所需的输入以将它们放入数组中,然后将它们显示在列表框中
items[itemcount,0] = ID;items[itemcount,1] = newprice;items[itemcount,2] = quant;items[itemcount,3] = desc;ListBox1.Items.Add(items[itemcount,0] + "\t" + items[itemcount,3] + "\t " + items[itemcount,2] + "\t " + items[itemcount,1]);ListBox1.Selectedindex = ListBox1.Items.Count - 1;
因此,如果用户想要从列表框中选择一个项目来删除该项目,则用户可以.在删除项目时,我意识到阵列不合适.所以我应该创建4个不同的列表并使用List.Remove方法删除它们或者是否有更好的方法我不需要处理4个不同的东西,用户也在运行使用WinXP的旧计算机我不得不担心表现有4个不同的名单?有没有像多维列表那样的东西?
谢谢你的帮助
解决方法 您正在尝试重新发明类的实例列表.就像是class Item { public int ID {get;set;} public double Price {get;set;} public double Quantity {get;set;} public string Description {get;set;}}var myItems = new List<Item>(); 总结 以上是内存溢出为你收集整理的c# – 我应该使用列表吗?全部内容,希望文章能够帮你解决c# – 我应该使用列表吗?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)