I am developing a small RTS in C#(with XNA).
I'm setting each unit "goto" position as the vector they should go to. Everything works fine if I don't compare the two Hashtables, but when I do, I get this "NullReferenceException was unhandled" annoying error.
Here's the piece of code I'm getting the error on:
if ( ((float)unit[(int)selectedunits[I+"ID"] + "posX"] != (float)cgoto[(int)selectedunits[I+"ID"] + "X"]) && ((float)unit[(int)selectedunits[I+"ID"] + "posY"] != (float)cgoto[(int)selectedunits[I+"ID"] + "Y"]) ) Hopefully this is specific enough.
NullReferenceException. This should highlight exactly where your null reference is.selectedunits[I+"ID"]is null. Please step through using Visual Studio and check the value at runtime.