I have an object reference that sets instances of an object, yet this message implies that I did not add to the Program.cs
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Program. [...]
Here is excerpt code in the Program.cs that I added list for Dog info and its vaccine.
Dictionary<string, string> dogInfo = new Dictionary<string, string>();
List<Dog> dogs = new List<Dog>();
List<string> dogVaccine = new List<string>();
dog.Vaccines.Add(vaccine); (in Program.cs)
public void AddVaccine(string vaccine)
{
Vaccines.Add(vaccine);
}
What I have tried:
I have tried to set a null checker in case the list is empty, etc., but it doesn't work, and I got the same error message after running this code.
I also modified the public void AddVaccine (string vaccine) to add the vaccine to the dog's list of vaccines; however, it doesn't work either. I do not understand what has my code gone wrong.