我想创建一个程序,我可以根据汽车的型号、类型和车牌保存汽车。我尝试将所有这些信息保存在字典中,但是当我通过第二个选项(“2. 搜索车辆”)搜索它们时,它们没有被保存。这是我的代码:
我应该怎么做才能让我的代码正常工作?我希望能够通过他们的车牌(瑞典车牌,ABC123)搜索汽车,但我无法弄清楚为什么没有保存我通过 ReadLines() 输入的字典值
Dictionary<string, string> newVehicle = new Dictionary<string, string>();
bool sunfleetAdminTools = true;
Dictionary<string, string> newVehicle = new Dictionary<string, string>();
do
{
WriteLine("1. Add Vehicle");
WriteLine("2. Search Vehicle");
WriteLine("3. Log Out");
ConsoleKeyInfo keyInput = ReadKey(true);
Clear();
switch (keyInput.Key)
{
case ConsoleKey.D1:
Clear();
bool invalidCarCredentials = true;
do
{
Write("Registration Number: ");
string regNumber = ReadLine();
newVehicle["Registration Number"] = regNumber;
Write("Brand: ");
string brand = ReadLine();
newVehicle["Brand"] = brand;
Write("Model: ");
string vehicleModel = ReadLine();
newVehicle["Model: "] = …Run Code Online (Sandbox Code Playgroud)