关于方法中的形参out

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace ConsoleApplication7
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             int sum1=100;
14             int result = Test(out sum1);
15             Console.WriteLine("numbere={0}  result={1}", sum1, result);//结果显示:numbere=11  result=200
16             Console.ReadKey();
17         }
18         public static int Test(out int a)//如果定义了out,则必须在下面的方法体中先定义a的值
19         {
20             a = 10;
21             a = a + 1;
22             return 200;
23         }
24     }
25 }

 

posted @ 2015-12-18 11:43  翻滚吧炒鸡蛋  阅读(238)  评论(0编辑  收藏  举报