scott griffin

scott griffin

  • NA
  • 5
  • 2.1k

Class with a List Add to list

Sep 27 2011 5:41 PM
Ok that subject was probably not the best in the world but this is what is going on.

I have some code that looks something like this.

public class CLASS
{

    public string firstprop {get; set;}

    public List<string> secondprop{get; set;}

}


now I could easily add a value to CLASS.firstprop = "mystring";

but when trying to add a value to CLASS.secondprop = "mystring"
it wont work I get a null exception.


I am trying to consume an xml file and fill the class with the data.

of course this is just thrown together code this is not what my code specifically looks like but it is close enough to get a good idea of what may be going wrong.


I am using a XMLReader to cycle through the XML file to get the data and it will get everything except it blows up when it gets to the list part








Answers (5)