コード例 #1
0
 private void lvAnimals_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     foreach (object selectedItem in lvAnimals.SelectedItems)
     {
         Animal selectedAnimal = lvAnimals.SelectedItem as Animal;
         if (selectedAnimal != null)
         {
             Dog dog = selectedAnimal as Dog;
             if (dog != null)
             {
                 dog.Bark();
             }
             selectedAnimal.Speak();
         }
     }
 }
コード例 #2
0
        private void Bark_Button_Click(object sender, RoutedEventArgs e)
        {
            Dog dog = new Dog();

            dog.Bark();
        }