When executing this code, I get a NullReferenceException on these lines:
List<Dictionary<Slot, string>> slots = new List<Dictionary<Slot, string>>();
Dictionary<Slot, string> somedict = new Dictionary<Slot, string>();
somedict.Add(new Slot(), "s");
this.slots.Add(somedict);
I cant figure out what is going on. I created a dict with the right items, but when I try to add it to the list, I just get a NullReferenceException....
I've been looking around MSDN and this website for about 2 hours, but no luck. Can anyone help me out? I'm just trying to store a Dictionary, into a list.
namespace hashtable
{
class Slot
{
string key;
string value;
public Slot()
{
this.key = null;
this.value = null;
}
}
class Bucket
{
public int count;
public int overflow;
public List<Dictionary<Slot, string>> slots;
Dictionary<Slot, string> somedict;
public Bucket()
{
this.count = 0;
this.overflow = -1;
List<Dictionary<Slot, string>> slots = new List<Dictionary<Slot, string>>();
Dictionary<Slot, string> somedict = new Dictionary<Slot, string>();
somedict.Add(new Slot(), "s");
this.slots.Add(somedict);
for (int i = 0; i < 3; ++i)
{
}
}
}
}