first time poster so forgive me if my formatting is off or anything :)
I'm working on my game engine in C# using XNA but when I check the name of a new node against existing nodes, the Assert fires off unpredictably even when there is no matching name in the list. Here is the code I'm referring too:
public void CheckNameIsUnique(string cName)
{
for (int i = 0; i < m_aNodeList.Count; ++i)
{
Debug.Assert(m_aNodeList[i].GetName().Equals(cName),
"USE OF NON-UNIQUE NAME: " + cName);
}
}
The assert will fire off -for example- when checking, "box1" and the only node in the list has the name "RootNode".
I get the same unpredictable results using:
string == string and string.CompareTo(string) > 0
Any ideas? =\
Assert is supposed to make sure the condition is TRUE. If it's false the assert will fail. What you want is to assert that it's NOT equal. use != and it should be fine.
The assertion fires if the condition is false. You have your conditional backwards. See here:
http://msdn.microsoft.com/en-us/library/e63efys0.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With