What does "using System" mean in C#?


What does

using System;

namespace HelloWorld
  class Program
    static void Main(string[] args)
      Console.WriteLine("Hello World!");

["using System"] mean? Why can’t you start your code without these lines?


The using System line means that you are using the System library in your project. Which gives you some useful classes and functions like Console class or the WriteLine function/method.

The namespace ProjectName is something that identifies and encapsulates your code within that namespace. It’s like package in Java. This is handy for organizing your codes.

class Program is the class name of your entry-point class. Unlike Java, which requires you to name it Main, you can name it whatever in C#.

And the static void Main(string[] args) is the entry-point method of your program. This method gets called before anything of your program.

And you can actually write a program without some of them in DotNet 5 and later as it now supports top level functions.

Answered By – S. M. JAHANGIR

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.