static void Main(string[] args) { MyClass myClass = new MyClass(); myClass.change = "no changes"; MyStruct myStruct = new MyStruct(); myStruct.change = "no changes"; ClassTaker(myClass); StructTaker(myStruct); Console.WriteLine(myClass.change);//changed Console.WriteLine(myStruct.change);// no changes Console.ReadLine(); }
static void Main(string[] args) { MyClass myClass1 = new MyClass(); MyStruct mySrtuct1 = new MyStruct(); myClass1.change = "didn't change"; mySrtuct1.change = "didn't change"; ClassTaker(myClass1); StructTaker(mySrtuct1); Console.WriteLine("Class " + myClass1.change); Console.WriteLine("Struct " + mySrtuct1.change); Console.ReadKey(); }
static void ClassTaker(MyClass myClass) { myClass.change = "changed"; }
public static void ClassTaker(MyClass myClass) { myClass._change = "Changed"; }
static void ClassTaker(MyClass myClass) { myClass.change = "Text from ClassTaker"; }
static void ClassTaker(MyClass myClass) { myClass.change = "изменено"; }