Skip to main content
3 of 5
split the if out
Polynomial
  • 28.4k
  • 13
  • 86
  • 110

How to compare two Hashtables?(C#)

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.