Hello, good evening. I know there are other posts about this error, but unfortunately it is not clear to me what I am failing. I leave the code, thanks.
PD;I want to show the elements inside the "flyable" collection
PD;I want to show the elements inside the "flyable" collection
C#:
usingSystem;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace INHERITANCE3
{
Class Program
{
static void Main(string[] args)
{
Cat g1 = new Cat();
g1.Name = " Pepe";
Dog p1 = new Dog();
List<Animal> animals = new List<Animal>();
animals.Add(g1);
animals.Add(p1);
animals.Add(new Fish());
animals.Add(new Canary());
animals.Add(new Eagle());
foreach (var item in animals)
{
Console.WriteLine(item.communicate());
}
List<Flyable> listavoladores = new List<Flyable>();//is not an object
flyinglist.Add(new Canary());
flyinglist.Add(new Eagle());
foreach (Flyable item in flyerlist)
{
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Last edited: