I am considering using a Linq Expression as a key in a dictionary. However, I am concerned that I will get strange results, because I don\'t know how Equality is determined
Comparing any two objects that aren't value types (including an Expression) with == compares object references, so they won't be equal. As a commenter noted, though, a dictionary would be using Equals
and GetHashCode
to determine equality, which would still by default end up determining that they were not equal.
You could probably create a class that inherits System.Linq.Expression
and override GetHashCode
and Equals
to use the result somehow, though, and use that as the key for your dictionary.