using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace test
{
    class Program
    {
        public int j;
        public void A()
        {
            int j = 1;   //与上面的j不冲突
            Console.WriteLine(j);
        }
        static void Main()
        {
            Program p = new Program();
            p.A();
            p.j = 2;
            p.A();
            Console.WriteLine(p.j);
         /*   for (int i = 0; i < 20; i++)
            {
                int k = i;
            }
            int k = 2;   //k的声明定义是错误的,因为子级for中已经有k了,出现冲突
          */
        }
    }
}


本文转载:CSDN博客