static void Main(string[] args) { MyNumberClass classVal = new MyNumberClass(); classVal.value = 3; MyNumberStruct structVal = new MyNumberStruct(); structVal.value = 3; AddTo(classVal, 1); AddTo(structVal, 1); Console.WriteLine("AddTo class = " + classVal); Console.WriteLine("AddTo struct = " + structVal); Console.ReadKey(); }
static void AddTo(MyNumberClass x, int y) { x.value += y; }