C# Challenge 19 - 引導式專案 - 在 C# 中開發條件式分支和迴圈結構

C# Challenge 19 - 引導式專案 - 在 C# 中開發條件式分支和迴圈結構

Microsoft 2023 年所提供的 C# codecamp 基礎課程,總共有 38 個單元,完成後就可以獲得 Certification ,今天要來跟大家分享的是第 19 單元的內容。

本節內容

Contoso Pets 專案

變數宣告

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// the ourAnimals array will store the following: 
string animalSpecies = "";
string animalID = "";
string animalAge = "";
string animalPhysicalDescription = "";
string animalPersonalityDescription = "";
string animalNickname = "";

// variables that support data entry
int maxPets = 8;
string? readResult;
string menuSelection = "";

// array used to store runtime data, there is no persisted data
string[,] ourAnimals = new string[maxPets, 6];

為 switch 陳述式保留條件撰寫的位置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
switch (menuSelection)
{
case "1":
// List all of our current pet information
Console.WriteLine("this app feature is coming soon - please check back to see progress.");
Console.WriteLine("Press the Enter key to continue.");
readResult = Console.ReadLine();
break;

case "2":
// List all of our current pet information
Console.WriteLine("this app feature is coming soon - please check back to see progress.");
Console.WriteLine("Press the Enter key to continue.");
readResult = Console.ReadLine();
break;

重點整理

跟之前一樣的引導式專案,沒有特別記錄什麼重點,就是按照他的指引一步一步完成這個專案內容。
那我們下次見ʘ‿ʘ


參考資料

評論