Exemple #1
0
        static void Main(string[] args)
        {
            Egg        egg = new Egg();         // Incubate is not accessible from egg.
            IHatchable h   = (IHatchable)egg;   // Incubate is accessible from h.

            using (MyPrecious p = new MyPrecious())
            {
                p.MakeMeInvisible();
            }
            // p.Dispose has been called, even
            // if an exception is thrown.
        }
Exemple #2
0
 /// <summary>
 /// Hatches an egg.
 /// </summary>
 /// <param name="egg">The egg to hatch.</param>
 private void HatchEgg(IHatchable egg)
 {
     // Hatch the egg.
     egg.Hatch();
 }
 /// <summary>
 /// Hatches a baby out of its egg.
 /// </summary>
 /// <param name="egg">The egg to hatch.</param>
 private void HatchEgg(IHatchable egg)
 {
     egg.Hatch();
 }