Let’s start from that project which we have created in our previous lecture
using
: Basically, with this keyword, we add a different namespace in our project. For the usage for their classes. In the case of C#, the System namespace is where many useful things are described. One of these useful things given C# is that the Console class can let me write things which can appear on the screen ahead of the user to this as Console I even have to inform the compiler I'm using the System namespace. The means that if I ask something by a specific name the compiler will look in the System to ascertain if there's anything matching that nameNamespace
: A namespace is a collection of classes and another namespace. We are using the namespace to organize our project.{ }
: These brackets (curly brackets) use to mark the beginning and end of the code block.Class
: Class is the container of method and other data.Main
: The main method is the entry point of the application.Console
: A class from the System namespaceWriteLine/Write
: A method in the console class that is used to print or display the value.Static
: This keyword makes sure that the function which follows is usually presentVoid
: A void is nothing. In programming terms, the void keyword means the method we are about to describe doesn't return anything of interest to us. The method will just do a job and then finish.The difference between writeline
and write
is that writeline
print new line every time but write
just print on the same line.
A big part of a well-written program in the comments that the programmer puts there. A program without comments is a bit like an airplane that has an autopilot but no windows. there is a chance that it might take you to the proper place, but it'll be very hard to inform where it's going from the inside.
When the C# compiler sees the "/*
" sequence which means the start of a comment it says to itself: I will ignore everything following until I see a */
which closes the comment.
/* This program works out glass and wood required for a double glazing salesman. */
Be generous together with your comments. they help to make your program much easier to understand. you will be very surprised to find that you quickly forget how you got your program to work. you can also use comments to keep people informed of the particular version of the program, when it was last modified and why, and the name of the programmer who wrote it – even if it was you.
If you're using an editor that supports syntax highlighting, you will find that comments are usually displayed in green.
Another form of comment makes use of the //
sequence. This marks the start of a comment which extends to the top of that particular line of code. it is useful for putting a quick note on the top of a statement:
position = position + 1; // move on to the next customer