要求:
/**
* 顯示商品名稱
* (1) . 創(chuàng)建一個長度為5的String數(shù)組,存儲商品名稱。
* (2) . 使用循環(huán)輸出商品名稱
**/
代碼:
namespace 作業(yè)1
{
class Program
{
static void Main(string[] args)
{
/**
* 顯示商品名稱
* (1) . 創(chuàng)建一個長度為5的String數(shù)組,存儲商品名稱。
* (2) . 使用循環(huán)輸出商品名稱
**/
try {
string[] scores = {"Nike背包","Adidas運動衫","李寧運動鞋","Kappa外套","361°腰包"};;
Console.WriteLine("本次活動特價商品有:");
for (int i = 0; i < scores.Length; i++)
{
Console.WriteLine(scores[i]);
}
}
catch {
Console.WriteLine("你輸入的數(shù)據(jù)有誤,請重新輸入!");
}
Console.ReadKey();
}
}
}
效果圖:

1.jpg