The name ‘…’ does not exist in the current context

dogList is local to the method Main. What you want to do instead is to place dogList outside of that scope.

public class Program
{
    static List<Dog> dogList = new List<Dog>();

...

Alternately you can send the list into your add method.

Leave a Comment