本帖最后由 邢凯 于 2014-8-3 11:22 编辑  
 
在方法中的return值怎么体现在使用中 
 
 
- using System;
 
 - using System.Collections.Generic;
 
 - using System.Linq;
 
 - using System.Text;
 
  
- namespace 异常
 
 - {
 
 -     class Program
 
 -     {
 
 -         static void Main(string[] args)
 
 -         {
 
 -             Console.WriteLine("请输入你的年龄");
 
 -             int age1 = int.Parse(Console.ReadLine());
 
 -             try
 
 -             {
 
 -                 string desc = GetAgeDesc(age1);
 
 -                 
 
 -             }
 
 -             catch(Exception ex)
 
 -             {
 
 -                 Console.WriteLine("数据错误+"+ex.Message);
 
 -             }
 
 -             Console.ReadKey();
 
 -         }
 
 -         static string GetAgeDesc(int age)
 
 -         {
 
 -             if (age >= 0 && age <= 10)
 
 -             {
 
 -                 return "婴幼儿";
 
 -             }
 
 -             else if (age > 10 && age < 18)
 
 -             {
 
 -                 return "青少年";
 
 -             }
 
 -             else if (age >= 18 && age < 150)
 
 -             {
 
 -                 return "成年人";
 
 -             }
 
 -             else if (age < 0)
 
 -             {
 
 -                 throw new Exception("您来自反物质世界吧");
 
 -             }
 
 -             else
 
 -             {
 
 -                 throw new Exception("您见过老佛爷吧");
 
 -             }
 
 -         }
 
 -     }
 
 -  
 
 - }
 
 
  复制代码 
 
这个是看视频自己写的 我想的是 自己输入一个年龄数字,然后返回得到我下面方法里面的东西,求大伙帮帮忙,我是个小白{:3_63:}    在请大伙教教我,这个return  的使用,我感觉我还是弄的不是很清楚  谢谢啦 |