コード例 #1
0
        //This throws an exception
        //static string PrintCarInfo(Car car)
        //{
        //    return string.Empty;
        //}
        static void Main(string[] args)
        {
            Car bmw     = new Car(100000, CarMake.BWM, new DateTime(2008, 01, 01), true, FuelType.Diesel);
            Car citroen = new Car(70000, CarMake.Citroen, new DateTime(2010, 05, 05), false, FuelType.Petrol);

            Car.PrintCarInfo(citroen);
            Console.WriteLine($"The bmw car has an id of {bmw.GetId()}");
            Console.WriteLine($"The citroen car has an id of {citroen.GetId()}");
            Console.WriteLine("Please enter car temperature in farenhights");
            string userInput    = Console.ReadLine();
            bool   isRealDouble = double.TryParse(userInput, out double ferenhights);

            if (isRealDouble)
            {
                double celsius = TemperatureConverter.ConvertFromFarenhietToCelsius(ferenhights);
                Console.WriteLine("The car has a temperature of " + celsius + " degrees");
            }
            Console.ReadLine();
        }