I have following piece of code and what I really don't understand is why I have two different references.
Dictionary<string, MyClass> tempDictionary = new Dictionary<string, MyClass>();
MyClass dbClass = db.Get<MyClass>().First();
MyClass localClass = null;
if(!tempDictionary.TryGetValue(dbClass.Id, out localClass))
{
tempDictionary.Add(localClass.Id, localClass = dbClass); // <-- notice this assignment (localClass = dbClass)
}
var localRef = localClass.GetHashCode(); // 90107424
var dbRef = dbClass.GetHashCode(); // 91823173
Why those references are different? Shouldn't point to the same object?