I am new to C# and also to an extend to other object oriented languages, so excuse my ignorance. I am trying to create a List variable that is tied to a class with two members, such as the following:
List<bus> bus_list_2d = new List<bus>();
public class bus
{
public string channel { get; set; }
public List<String> label { get; set; }
}
I will be parsing through an xml document that has a channel assigned which holds multiple buffers labels. The exact number of channels is not known and same for the buffer labels, hence why I was wanting to use the List.
I was wondering how would I create the Add functionality where I would add a single channel and then keep on adding the label items and then move on to the next channel and add label items under that and so on. Can someone give me an example snippet for this please?
It is probably easier to add to a temporary variable and then add that to
bus_list_2d:Also, you probably want to have the constructor of the
busclass initializelabelto a newList<string>so that you don't have to explicitly do it. Also please follow the naming conventions. Classes, Properties, and Methods are capitalized and use camel case.