Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created December 26, 2016 17:07
public class SomeClass {
public string someField;
}
var instance1 = new SomeClass(); // instance1 is a reference to an object in memory
var instance2 = instance1; // instance2 is a copy of the reference
instance2.someField = "changed";
instance1.someField == instace2.someField // -> true
instace2 = new SomeClass();
instance2.someField = "changed again";
instance1.someField != instance2.someField // -> true -> they are different objects
instance1.someField; // -> "changed" -> nothing changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment