Song mySong = new Song(); mySong.Title = "Bohemian Rhapsody"; mySong.Artist = "Queen"; mySong.Album = "A Night at the Opera"; mySong.Length = TimeSpan.FromMinutes(5.55);
ListThis example creates a List of Song objects and adds three songs to it with their respective properties. Package/Library: The Song class belongs to the System.Media namespace and is part of the .NET Framework Class Library.myPlaylist = new List (); myPlaylist.Add(new Song() { Title = "Hallelujah", Artist = "Jeff Buckley", Length = TimeSpan.FromMinutes(6.56) }); myPlaylist.Add(new Song() { Title = "Stairway to Heaven", Artist = "Led Zeppelin", Length = TimeSpan.FromMinutes(8.02) }); myPlaylist.Add(new Song() { Title = "Imagine", Artist = "John Lennon", Length = TimeSpan.FromMinutes(3.04) });