In the previous chapter, we tried to write a piece of the text of the console, to see some real progress in our first C # application, we did not say much on the lines of code, so this chapter is an explanation of the world. As you can see from the code, some lines look the same, so we will bring them back to the group for a personal explanation. Let's start with the least and most common characters in our code: {and} they are often referred to as curly braces, and in C #, they mark the beginning and end of the logical block of code. Curl braces are used in many other languages, including C ++, Java, Javascript and many other languages. As you can see in the code, they wrap many lines that come together. In later examples, it will be clear how they are used.
Now let's start from the beginning:
using System;
using System.Collections.Generic;
using System.Text;
Is a keyword used by the blue highlighted editor, the keyword uses a namespace, and this is a collection of namespace classes. Classes bring us some kind of functionality, and when we work with advanced IDEs like Visual C # Express, it will generally create parts of the trivial code for us. In this case, we have created a class for us , And imported names that are necessary or expected to be used in general. In this case, 3 namespaces are imported for us, each of which is imported. For example, we use console classes, which are part of the system namespace.
As you can see, we also get our namespace:
namespace ConsoleApplication1
The namespace console application 1 is now the main namespace for this application, and new classes will be a part of it by default. Obviously, you can change this, and you can create a square in the alias space. In that case, you have to do this in order to use this new namespace in your application with the statement, using any other namespace.
After this, we define our class because C # is actually an object-oriented language, in fact, every line of code actually does something, it is wrapped inside the class. In this case, the class is called only program goes:
class Program
We can do even more classes, even in the same file. For now, we only need one class. In a class, many variables, properties and methods, concepts can be included which we will later in depth. For now, you have to know that there is only one way in our present class and nothing else has been declared:
Static zero main (string [] args)
This line is probably the most complex in this example, let's divide it a little bit. The first word is stable, static keyword tells us that this method should be attainable without a class, but in our chapter about classes about it
The next keyword is zero, and tells us how to return the method. For example, the int integer or a string of text can be, but in this situation, we do not want our method to return anything, or zero, which is not equal to any type.
The next word is the main, which is simply the name of our method. This method is the so-called entry point of our application, i.e., the first part of the code to be executed, and in our example, the only piece to be executed
Now, after the name of a method, the set of arguments can be specified within a set of brackets. In our example, there is only one argument in our method, which is called AGR. The type of argument is a string, or more accurate, an array of stars, but more on that later. If you think about it, it makes sense, because the Windows application can always be said with an optical set of arguments. These logic will be passed in our main method as text strings.
and all. Now you should have a basic understanding of our first C # application, as well as basic principles that work on console applications.