环境:net framework 4.5.2
struct是值传递(拷贝)




public class Test1 {public Test1(int x,int y){this.X = x;this.Y = y;}public int X {get;set;}public int Y {get;set;}}public struct Test2 {public Test2(int x,int y){this.X = x;this.Y = y;}public int X {get;set;}public int Y {get;set;}}public class Program {private void EditTest(Test1 T) {T.X = 500;T.Y = 1000;}private void EditTest(Test2 T) {T.X = 5000;T.Y = 10000;}static void Main(string [] args) {Test1 t1 = new Test1(10,20);Test2 t2 = new Test2(30,40);Program pro = new Program();pro.EditTest(t1);pro.EditTest(t2);Console.WriteLine("x = {0},y = {1}",t1.X,t1.Y); //X = 500, Y = 1000Console.WriteLine("x = {0},y = {1}", t2.X, t2.Y);//X = 30, Y = 40}}
