Should I be using lists?

arrays, asp.net, c#, list, multidimensional-array

Solution

You are trying to reinvent List of instances of a class. Something like

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>();

Problem

So at the moment I have a multidimensional array ``` string[,] items = new string[100, 4]; ``` I then gather the needed inputs to put them into the array, and then display them in a listbox ``` 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; ``` So then the user can if they want select an item from the listbox to delete that item. When it came to deleting an item I realized that an array is not suitable. So should I create 4 different lists and use the list.Remove method to delete them or is there a better way that I dont have to work on 4 different things, also the user is running an older computer with WinXP would i have to worry about performance with 4 different lists? Is there anything such as a multidimensional list? Thanks heaps for your help

Original source