在不同的情况下使用一个情况
本文关键字:一个 情况 情况下 | 更新日期: 2023-09-27 18:17:52
我需要在"Case 3"里面使用"Case 2",但每次我这样做,它都不起作用。有人能帮帮我吗?我不知道我是不是在代码里面做错了什么…
我希望你们中的一些人能帮助我。
我当前使用的代码:
case 2:
Console.WriteLine("Gekozen actie: 2. Gegevens MP3 speler opslaan");
Console.WriteLine("Type de ID: ");
int id = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type de Maker: ");
string MAKE = Convert.ToString(Console.ReadLine());
Console.WriteLine("Type de Model : ");
var MODEL = Convert.ToString(Console.ReadLine());
Console.WriteLine("Type de MBGrootte: ");
int MBSize = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type de Prijs: ");
var PRICE = Convert.ToString(Console.ReadLine());
Console.ReadLine();
Console.WriteLine("Ingevoerde gegevens: " +
Environment.NewLine + "Uw ID: " + id +
Environment.NewLine + "Uw Maker: " + MAKE +
Environment.NewLine + "Uw Model: " + MODEL +
Environment.NewLine + "Uw MBGrootte: " + MBSize +
Environment.NewLine + "Uw Prijs: " + PRICE);
Console.ReadLine();
break;
case 3:
Console.WriteLine("ID: 1" +
Environment.NewLine + "Make: Get Technologies .inc" +
Environment.NewLine + "Model: HF 410" +
Environment.NewLine + "MBSize: 4096" +
Environment.NewLine + "Price: $129.95");
Console.ReadLine();
break;
(我需要"CASE 2"下面的"CASE 3"(在Console.ReadLine()下))对不起,我的英语不好!
case 2:
case 3:
if (yourVar == 3)
{
Console.WriteLine("ID: 1" + Environment.NewLine +
"Make: Get Technologies .inc" + Environment.NewLine +
"Model: HF 410" + Environment.NewLine +
"MBSize: 4096" + Environment.NewLine + "Price: $129.95");
Console.ReadLine();
}
Console.WriteLine("Gekozen actie: 2. Gegevens MP3 speler opslaan");
Console.WriteLine("Type de ID: ");
int id = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type de Maker: ");
string MAKE = Convert.ToString(Console.ReadLine());
Console.WriteLine("Type de Model : ");
var MODEL = Convert.ToString(Console.ReadLine());
Console.WriteLine("Type de MBGrootte: ");
int MBSize = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type de Prijs: ");
var PRICE = Convert.ToString(Console.ReadLine());
Console.ReadLine();
Console.WriteLine("Ingevoerde gegevens: " +
Environment.NewLine + "Uw ID: " + id +
Environment.NewLine + "Uw Maker: " + MAKE +
Environment.NewLine + "Uw Model: " + MODEL +
Environment.NewLine + "Uw MBGrootte: " + MBSize +
Environment.NewLine + "Uw Prijs: " + PRICE);
Console.ReadLine();
break;
将Case 2
放入方法中,然后在Case 2
和Case 3
中使用此方法