示例#1
0
文件: Program.cs 项目: Pianykh/HW8
        private static void Main()
        {
            Console.InputEncoding  = Encoding.Unicode;
            Console.OutputEncoding = Encoding.Unicode;

            var carAsStruct = new CarAsStruct {
                IsStarted = false, Color = "red"
            };

            Console.WriteLine($"{carAsStruct.IsStarted}, {carAsStruct.Color}");
            ChangeCarStructParameters(ref carAsStruct, true, "purple");
            Console.WriteLine($"{carAsStruct.IsStarted}, {carAsStruct.Color}");

            var carAsObject = new CarAsObject();

            Console.WriteLine($"{carAsObject.IsStarted}, {carAsObject.Color}");
            ChangeCarObjectParameters(carAsObject, true, "purple");
            Console.WriteLine($"{carAsObject.IsStarted}, {carAsObject.Color}");
        }
示例#2
0
文件: Program.cs 项目: Pianykh/HW8
 static void ChangeCarObjectParameters(CarAsObject carAsObject, bool isStarted, string color)
 {
     carAsObject.IsStarted = isStarted;
     carAsObject.Color     = color;
 }