static void PlayWithValue(out MyValue value) { //value = new MyValue("yay out", DateTime.MaxValue); value.MyString = "Changed MyString!"; value.MyDate = DateTime.Now.AddDays(2); Console.WriteLine(new { value.MyDate, value.MyString }); }
static void ValRefFun() { var value1 = new MyValue("Value String", new DateTime(2010, 1, 1)); var value2 = default(MyValue); value2.MyString = "Value String 2"; value2.MyDate = DateTime.MinValue; Console.WriteLine("Before: " + new { value1.MyDate, value1.MyString }); PlayWithValue(out value1); Console.WriteLine("After: " + new { value1.MyDate, value1.MyString }); var Class1 = new MyClass("Class String", new DateTime(2010, 1, 1)); Console.WriteLine("Before: " + new { Class1.MyDate, MyString = Class1.myString }); PlayWithClass(Class1); Console.WriteLine("After: " + new { Class1.MyDate, MyString = Class1.myString }); }