[Help] I am working through the beginner’s C# tutorial from the MVA, but I get an usual error when I try to debug.

The video that I copied my code from is this

The code I have copied is as follows:

"using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace ConsoleApplication11 { class Program { static void Main(string[] args) { Car myNewCar = new Car(); myNewCar.Make = "Oldsmobile"; myNewCar.Model = "Cutlas Supreme"; myNewCar.Year = 1986; myNewCar.Color = "Silver";

 Console.WriteLine("{0} - {1) - {2}", myNewCar.Make, myNewCar.Model, myNewCar.Color); //double marketValueOfCar = determineMarketValue(myNewCar); Console.WriteLine("Car's value: {0:C}", myNewCar.determineMarketValue()); Console.ReadLine(); } private static double determineMarketValue (Car _car) { double carValue = 100.0; return carValue; } } class Car { public string Make {get; set;} public string Model {get; set;} public int Year {get; set;} public string Color {get; set;} public double determineMarketValue() { double carValue = 100.0; if (this.Year > 1990) carValue = 10000.0; else carValue = 2000.0; return carValue; } } 

} "

When I attempt to debug, this section is highlighted

"Console.WriteLine("{0} – {1) – {2}", myNewCar.Make, myNewCar.Model, myNewCar.Color); "

With the error message: "An unhandled exception of the type 'System.FormatException' occurred in mscorlib.dll

Additional information: Input string was not in a correct format."

by ProjectFrostbite via /r/csharp

Leave a Reply