Tuesday 22 July 2014

Use of global contextual keyword

The global is contextual keyword, when it comes before the :: operator, refers to the global namespace of .Net


Check example :

namespace TestWinform.test
{
    public class globalClass
    {
        public void TestMethod()
        {
            // Here you can able to access Default system Namespace of .Net framework
            global::System.Console.Write("");

            // This is the class of   "TestWinform.test"  namespace
            System sys = new System();
            sys.Console();
        }       
    }

    public class System
    {
        public void Console()
        {

        }
    }
}



No comments:

Post a Comment