using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MemoryTest5 { struct S1 { public int x; public int y; } class C1 { public int x; public int y; } class Program { public static void f1(S1 structParam) { structParam.x++; structParam.y++; } public static void f2(ref S1 structParam) { structParam.x++; structParam.y++; } public static void f3(C1 classParam) { classParam.x++; classParam.y++; } public static void f4(C1 classParam) { classParam = new C1(); classParam.x = 100; classParam.y = 100; } public static void f5(ref C1 classParam) { classParam = new C1(); classParam.x = 100; classParam.y = 100; } static void Main(string[] args) { S1 structvar = new S1(); C1 classvar = new C1(); // structVar.x = structVar.y = classvar.x = classvar.y = 0; f1(structvar); Console.WriteLine(structvar.x + "," + structvar.y); // structVar.x ? structVar.y ? f2(ref structvar); Console.WriteLine(structvar.x + "," + structvar.y); // structVar.x ? structVar.y ? f3(classvar); Console.WriteLine(classvar.x + "," + classvar.y); // classvar.x ? classvar.y ? f4(classvar); Console.WriteLine(classvar.x + "," + classvar.y); // classvar.x ? classvar.y ? f5(ref classvar); Console.WriteLine(classvar.x + "," + classvar.y); // classvar.x ? classvar.y ? Console.ReadKey(); } } }