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 ChangeCarStructParameters(ref CarAsStruct carAsStruct, bool isStarted, string color)
 {
     carAsStruct.IsStarted = isStarted;
     carAsStruct.Color     = color;
 }