choosesubject c# switch
更新時間:2009年07月03日 15:56:21 作者:
c# switch 實例代碼。
復(fù)制代碼 代碼如下:
using System;
class ChooseSubject
{
static void Main()
{
int i;
string str;
Console.WriteLine ("Please choose your favorite subjects:-1 is quit.");
Console.WriteLine ("1.Chinese.");
Console.WriteLine ("2.Maths.");
Console.WriteLine ("3.English.");
Console.WriteLine ("4.Physical.");
Console.WriteLine ("-1 is quit.");
do
{
str=Console.ReadLine ();
i=Int32.Parse (str);
switch(i)
{
case 1:
Console.WriteLine ("You like chinese very much.");
break;
case 2:
Console.WriteLine ("You like maths very much.");
break;
case 3:
Console.WriteLine ("You like english very much.");
break;
case 4:
Console.WriteLine ("You like physical very much.");
break;
case -1:
break;
default:
Console.WriteLine ("I'm sorry.You can't choose this subject.");
break;
}
}while(i!=-1);
Console.WriteLine ("Byebye!");
}
}
相關(guān)文章
C#創(chuàng)建WCF服務(wù)控制臺應(yīng)用程序詳解
這篇文章主要為大家詳細介紹了C#創(chuàng)建WCF服務(wù)控制臺應(yīng)用程序,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-07-07
深入分析緩存依賴中cachedependency對象及周邊小講
本篇文章是對緩存依賴中cachedependency對象進行了詳細的分析介紹,需要的朋友參考下2013-06-06
C#學(xué)習(xí)基礎(chǔ)概念二十五問 11-15
C#學(xué)習(xí)基礎(chǔ)概念二十五問 11-15...2007-04-04

