c# - Why I receive different reference on assign? -
i have following piece of code , don't understand why have 2 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 assignment (localclass = dbclass) } var localref = localclass.gethashcode(); // 90107424 var dbref = dbclass.gethashcode(); // 91823173
why references different? shouldn't point same object?
Comments
Post a Comment