Friday, 23 December 2016

Global keyword in CSharp example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Global_keyword_in_CSharp
    static class System // we just removed Program
        static class Console {
            public static void Write(string str) {
                global::System.Console.WriteLine(DateTime.Now.ToString() + " " + str);

        static void Main(string[] args)


Finally what we got as output are:
12/23/2016 12:48:56 PM ASPtRICKE.NET

It means that we can redefine the classes, property and methods according to application demand.
In that case if we need to distinguished with them we could use global keyword in .net.
As global:: keyword ensure that you are going to access base System.Object.