list - 'System.NullReferenceException' with templates c# -


i have code class state holds template. class cell t. i'm trying add object of type state list, , gives me error if points null, though debug , see has values, expect.

public abstract class searcher<t> t : iequatable<t> {     list<state<t>> solution;     public list<state<t>> backtrace(state<t> n , isearchable<t> searchable)     {         while (! ( n.getprevious().equals(searchable.getinitialstate())))         {             if (n != null)                 solution.add(n); //error, null exception }}      "'system.nullreferenceexception'.." 

what's weird gets past if state, , still won't add list because gives me error. state class is:

public class state<t> t : iequatable<t> {     public t state;         // state represented string/cell     private state<t> camefrom;  // state came      public state<t> getprevious()     {         return camefrom;     } 

any help..?


Comments