国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

黑馬程序員_異常實例

2019-11-17 03:15:25
字體:
來源:轉載
供稿:網友

黑馬程序員_異常實例

using System;

using System.Collections.Generic;

using System.Linq; using System.Text;

//2014.3.14

namespace _6.異常

{

class PRogram

{

static void Main(string[] args)

{

try

{

Console.WriteLine("Convert之前");

int a = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Convert之后");

}

catch (Exception ex)

{

Console.WriteLine("輸入錯誤:"+ex.Message+"異常堆棧:"+ex.StackTrace);

}

try

{

Console.WriteLine("請輸入你的年齡:");

int s = Convert.ToInt32(Console.ReadLine());

string desc = GetAgeDesc(s);

Console.WriteLine(desc);

}

catch (Exception ex)

{

Console.WriteLine("數據錯誤,"+ex.Message);

}

Console.ReadKey();

}

static string GetAgeDesc(int age)

{

if (age >= 0 && age <= 3)

{

return "嬰幼兒";

}

else if (age > 3 && age < 18)

{

return "青少年";

}

else if (age >=18 && age < 60)

{

return "成年人";

}

else if (age >= 60 && age < 100)

{

return "老年人";

}

else

{

throw new Exception("自己創建的ex.Message");

}

}

}

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 崇义县| 贵阳市| 东港市| 临沂市| 迁安市| 龙口市| 汨罗市| 邳州市| 万年县| 开封市| 曲阳县| 乐至县| 沾化县| 毕节市| 常山县| 义马市| 关岭| 辽中县| 余干县| 如东县| 西峡县| 东平县| 长葛市| 治县。| 汉川市| 亚东县| 连山| 青浦区| 奉新县| 卫辉市| 师宗县| 阿拉善左旗| 台东县| 久治县| 云龙县| 泰兴市| 黄梅县| 睢宁县| 中卫市| 敦煌市| 边坝县|