码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-11-24 21:35:19      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:str   static   ram   read   int   turn   nbsp   blog   sharp   

 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);
        }
    }    

 

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

标签:str   static   ram   read   int   turn   nbsp   blog   sharp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!