Why are C# structs immutable?
Compiler Error CS1612 Cannot modify the return value of 'expression' because it is not a variable class Transform { public Point p { get ; set ; } public Point p2; public void ShowV() { Console.WriteLine(p.X + " ... " + p.Y); } } [Test] public void TestChuck() { Transform t = new Transform(); t.p.X = 1 ; t.p2.X = 2 ; t.ShowV(); Console.Read(); } t.p = new Point(); 这个可以,set可以工作。 但是get出来的是value Why are C# structs immutable? 问题 I was just curious to know why structs, strings etc are immutable? What is the reason for making them immutable and rest of the objects as mutable. What are the things