Exemple #1
0
        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}");
        }
Exemple #2
0
 static void ChangeCarObjectParameters(CarAsObject carAsObject, bool isStarted, string color)
 {
     carAsObject.IsStarted = isStarted;
     carAsObject.Color     = color;
 }