Exemple #1
0
        public static void Print(object obj)
        {
            IPlant plant = obj as IPlant;

            if (plant as IPlant != null)
            {
                Console.WriteLine("---------------");
                Console.WriteLine(plant.ToString());
            }
            else
            {
                throw new InvalidPlantException("Невозможно привести объект " + obj.ToString() + " к типу Iplant");
                //Console.WriteLine("---------------Print for " + obj.GetType() + "---------------");
                //Console.WriteLine(obj.ToString());
            }
        }
Exemple #2
0
 public static void Print(IPlant plant)
 {
     Console.WriteLine("---------------");
     Console.WriteLine(plant.ToString());
 }