Are 2 dimensional Lists possible in c#?
As Jon Skeet mentioned you can do it with a List<Track>
instead. The Track class would look something like this:
public class Track {
public int TrackID { get; set; }
public string Name { get; set; }
public string Artist { get; set; }
public string Album { get; set; }
public int PlayCount { get; set; }
public int SkipCount { get; set; }
}
And to create a track list as a List<Track>
you simply do this:
var trackList = new List<Track>();
Adding tracks can be as simple as this:
trackList.add( new Track {
TrackID = 1234,
Name = "I'm Gonna Be (500 Miles)",
Artist = "The Proclaimers",
Album = "Finest",
PlayCount = 10,
SkipCount = 1
});
Accessing tracks can be done with the indexing operator:
Track firstTrack = trackList[0];
Hope this helps.
Well you certainly can use a List<List<string>>
where you'd then write:
List<string> track = new List<string>();
track.Add("2349");
track.Add("The Prime Time of Your Life");
// etc
matrix.Add(track);
But why would you do that instead of building your own class to represent a track, with Track ID, Name, Artist, Album, Play Count and Skip Count properties? Then just have a List<Track>
.