Пример #1
0
        public static void DoSomething(FatherClass f)
        {
            switch (f.Type)
            {
            case "FatherClass":
                f.Method();
                break;

            case "SonClass":
                ((SonClass)f).SonMethod();
                break;

            case "GrandsonClass":
                ((GrandsonClass)f).GrandsonMethod();
                break;
            }
        }
Пример #2
0
 public static void DoSomething(FatherClass f)
 {
     switch (f.Type)
     {
         case "FatherClass":
             f.Method();
             break;
         case "SonClass":
             ((SonClass)f).SonMethod();
             break;
         case "GrandsonClass":
             ((GrandsonClass)f).GrandsonMethod();
             break;
     }
 }