using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
           /* try
            {
                int i = Convert.ToInt32("ABC");
            }
            catch (Exception ex)
            {
                Console.WriteLine("数据错误!" + ex.Message + "异常堆栈:" + ex.StackTrace);
            }
            * */
            try
            {
                string agedesc = GetAgeDsc(20);
                Console.WriteLine(agedesc);//这个语句没有上的话,正常岁数不会有任何提示,只有抛出异常的时候才出现提示

            }
            catch(Exception ex)
            {
                Console.WriteLine("数据错误:" + ex.Message);
            }
            Console.ReadKey();
        }
        static string GetAgeDsc(int age)
        {

            if(age > 0 && age <= 3)
            {
                return ("婴幼儿");
            }
            else if (age > 3 && age <= 18)
            {
                return ("青少年");
            }
            else if (age > 19 && age < 150)
            {
                return ("成年人");
            }

            if (age < 0)
            {
                throw new Exception("您来自反物质世界吧?");
            }

            else
            {
                throw new Exception("您见过老佛爷吗?");
            }

        }
    }
}