Global keyword usage for C # in ASP.net

Source: Internet
Author: User

The following code:

The code is as follows Copy Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
Namespace Globalfunc
{
    class program
    {
 &N bsp;      static void Main (string[] args)
        {
            System sys = new system ();
            global::system.console.writeline ("Global .");
            Global::system.console.readkey ();
       }
   }
    public class System {}

 
Although a System namespace is using, there is also a public class system{below ...} class, so that if you use System.Console.WriteLine directly, you will get an error, because you will find the nearest system class, there is no Console in the system class. So if you need to use it, you need to use Global::system.console.writeline as above, because classes that use the global tag start looking globally, and my understanding is to look inside the System class from the outermost.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.