欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

深入Ref,Out的理解及其使用

 更新時間:2013年06月09日 10:44:49   作者:  
本篇文章是對Ref與Out進行了詳細的分析介紹,需要的朋友參考下
復制代碼 代碼如下:

    class Program 
       { 
           //使用out后必須對變量賦值 
           public void TestOut(out int x, out int y) 
           { 
               x = 1; 
               y = 2; 
           } 
           //此時傳進來的值分別為x1:10,y1:11,輸出之后的x1的值為2 

           public void TestRef(ref int x, ref int y) 
           { 
               //引用剪剪那句話傳進來的是豬,出來的可能是頭牛(很精辟!) 
               x = 2; 

           } 
           static void Main(string[] args) 
           { 
               int x; 
               int y; 
               Program P1 = new Program(); 
               P1.TestOut(out x,out y); 
               Console.WriteLine("x={0},y={1}", x, y); 
               //在使用之前ref必須對變量賦值 
               int x1 = 10; 
               int Y1 = 11; 
               P1.TestRef(ref x1,ref Y1); 
               Console.WriteLine("x1={0},y1={1}", x1, Y1); 
           } 
       } 

相關(guān)文章

最新評論