示例#1
0
 private static void WriteSound(IMakeSounds soundMaker, Func <IMakeSounds, string> sound)
 {
     if (soundMaker != null)
     {
         Console.WriteLine($"*** {sound(soundMaker)} ***");
     }
 }
示例#2
0
 private static void MakeSounds(IMakeSounds soundMaker)
 {
     Console.WriteLine($"A surprised {soundMaker.GetType().Name} makes the sound {soundMaker.Surprise()}");
     Console.WriteLine($"A contented {soundMaker.GetType().Name} makes the sound {soundMaker.Contentment()}");
 }