コード例 #1
0
        //c#6 format string

        public void StringFormatOlder()
        {
            Rockband1 metallica        = new Rockband1("Metallica", 4, 50);
            string    formatExampleOne = string.Format("The band is called {0}, they have the fancy name of {1}, they have {2} members and require {3:c} for a concert."
                                                       , metallica.Name, metallica.GetFancyName(), metallica.NumberOfMembers, metallica.ConcertFee);

            Debug.WriteLine(formatExampleOne);
        }
コード例 #2
0
 public void StringFormatNewer()
 {
     Rockband1 metallica        = new Rockband1("Metallica", 4, 50);
     string    formatExampleTwo = $"The band is called {metallica.Name}, they have the fancy name of {metallica.GetFancyName()}, they have {metallica.NumberOfMembers} members and require {metallica.ConcertFee:c} for a concert.";
 }