首页 > 其他 > 详细

方法的调用和字段的作用域

时间:2016-11-24 21:32:19      阅读:170      评论:0      收藏:0      [点我收藏+]
 class Program
    {
        

        //虽然是公有字段,但方法中失效。
        public static int _number = 10;


        static void Main(string[] args)
        {
            
            int a = 3;
            int res = Test(a);
            Console.WriteLine(res);
           //  Console.WriteLine(_number);
            Console.ReadKey();
        }
        public static int Test(int a)
        {
            a = a + 5;
            return a;
          //   Console.WriteLine(_number);
        }


        public static void TestTwo()
        {
          // Console.WriteLine(_number);
        }
    }    

 

方法的调用和字段的作用域

原文:http://www.cnblogs.com/hao-1234-1234/p/6099466.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!