What do the first few lines of most pieces of C# code mean?

228 viewsOtherTechnology

e.g. “using System;” , “namespace MyApplication” , “class Program” , “static void Main(string\[\] args)” and what classes and namespaces are

In: Technology

5 Answers

Anonymous 0 Comments

Your code will need to rely on functionalities somebody else built to be any use (even some calculations or display of any kind needs a lot of code). To bypass writing everything from scratch, you reuse somebody elses code, organized into libraries – and that is what usings are, the libraries you want to reuse.

The class line tells your code how your little piece of code is grouped, into a class. A class will be the place you store data but also do stuff, through methods/functions. All of these need to belong somewhere, so your class is the main building block.

Namespace is a group of classes.

Static void main is your method which gets called when the program is executed. Most programs need to have at least the main method, and this going to be your entry point, from where your program can either branch out into more complex stuff or just do simple things and end. Void means it doesn’t give any result, which makes sense because when main itself ends, the program pretty much ends, so there is no use in giving a result.

You are viewing 1 out of 5 answers, click here to view all answers.