using System;
public static class CarExtensions
{
public static void Beep(this Program.Car car)
// Note: car.make instead of car?.make
Console.WriteLine("Car with make: " + car.make + " beeps. Beep! Beep!");
}
public class Program
public class Car
public int make { get; set; }
public Car(int make)
this.make = make;
public static void Main()
Car car = new Car(1999);
Car carNull = null;
// Here we are going to try out our horn. Beep beep.
car.Beep();
carNull?.Beep();
// The second car is null, so only 1 beep.
// But we did not get a null reference exception. Meaning that car.make is sufficient, we dont need car?.make