I can see two possibilities:
-
useaction.Postcondition[goalneeds]
andcurrent[goalneeds]
return something other than abool
. They return an object of a class that has aToString()
method which sometimes returns the string"True"
. The specific objects returned in your case both generate"True"
but are not the same object, so==
is false (or the type of those objects overloads the==
operator in such a way that it returns false, or some other object whoseToString()
method returns"False"
).(Apparently this turned out to be the case, although the “class” is actually just
object
with a boxedbool
inside. This does have the described effect because==
performs reference equality in this case.) -
The indexer of either
useaction.Postcondition
orcurrent
(or both) has a side-effect that alters its own value. As a result, the second invocation of it returns a different result than the first.
Both of these should be immediately visible in the debugger if you just stepped to the line of code you quoted and used the Watch window.
0
solved c#: (True==True) returning False [closed]