当前位置:首页 > C#教程 > C#进阶

C#按输出传递参数

using System;

namespace CalculatorApplication {

   class NumberManipulator {

      public void getValue(out int x ) {
         int temp = 5;
         x = temp;
      }

      static void Main(string[] args) {
         NumberManipulator n = new NumberManipulator();

         /* local variable definition */
         int a = 100;

         Console.WriteLine("Before method call, value of a : {0}", a);

         /* calling a function to get the value */
         n.getValue(out a);

         Console.WriteLine("After method call, value of a : {0}", a);
         Console.ReadLine();

      }
   }
}

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!