I feel pretty ignorant asking this, but would someone be able to explain to me why this is happening?
class MyClass{ public int i {get; set; } } class Program { static void Main(string[] args) { MyClass a = new MyClass(); MyClass b = new MyClass(); b.i = 2; a = b; a.i = 1; Console.Write(b.i + "\n"); //Outputs 1 } }
This makes sense to me were I using pointers and all that great stuff, but I was under the impression that with C# that "b" would remain independent from "a."
Am I just using some terribly bad practice? Maybe someone could point me towards something that explains why this is so in C#?
Thanks.