This driving me nuts. I can't get reach of Toy and really don't know why...
This is what the code looks like stripped down:
This is what the code looks like stripped down:
C#:
abstract class Animal
{
public List<Toy> Toy { get; set; } = new List<Toy>();
}
C#:
abstract class Toy
{
}
C#:
class Petowner
{
int i = 1;
foreach (var toy in Toy) // 'Toy' is a type, which is not valid in the given context
{
if (Toy.OfType<Ball>().Any()) // 'Toy' does not contain a definition for 'OfType'
{
if (toy is Ball ball)
{
Console.WriteLine(" {0} {1}", i, toy);
i++;
}
}
}
}