Thursday, March 1, 2012

use global variable with same name of Local variable


 public class Demo1
    {
        int a = 10;
        public  void ff()
        {
            int a = 11;
            Console.WriteLine("a={0}", this.a);
        }


   class Program
    {
        static void Main(string[] args)
        {
              Demo1 ng = new   Demo1();
             ng.ff();

            Console.WriteLine("Press any key to close........");
            Console.ReadKey();

        }
}


Output:
-----------------------------------
a=10
Press any key to close........
-----------------------------------

No comments:

Post a Comment

Hash Table in C#

 The Hashtable is a non-generic collection and used to store the key/value pairs based on the hash code of the key. Key will be used to acce...