Exemple #1
0
        static void Main(string[] args)
        {
            // Create a new music track instance

            MusicTrack track = new MusicTrack(artist: "Rob Miles", title: "My Way", length: 120);

            // Use the copy constructor to send a copy of the track to be printed
            // Changes made by the PrintTrack method will have no effect on the original
            PrintTrack(new MusicTrack(track));

            Console.WriteLine(track.Artist);
            Console.ReadKey();
        }
Exemple #2
0
 // Naughty PrintTrack method that changes the Artist property of the
 // track being printed.
 static void PrintTrack(MusicTrack track)
 {
     track.Artist = "Fred Bloggs";
 }
Exemple #3
0
 public MusicTrack(MusicTrack source)
 {
     Artist = source.Artist;
     Title  = source.Title;
     Length = source.Length;
 }