May 12
Below is the simple helloworld source code and the source code evolved based on the learning content: Class helloworld
{// Each. NET application must contain one and only one main method, which is the entry to the entire application // and m must be capitalized. Public static void main () {// Here we only output Hello world! System. Console. writeline ("Hello world! ") ;}} Using system; // tell the runtime environment which namespaces and methods should be referenced in this class, however, this does not increase the size of the generated program.
{Public static void main () {// you can see that the previous system. is omitted in the following line of code, and only console. writeline ("Hello world! "); // Writeline () is the method in the console class in the system namespace, in the previous Code instance, we wrote a complete path // to tell the runtime environment where our method can be found. If we only enter the console. writeline () is called, // The runtime environment will be confused, and I don't know where to find this class to call writeline (). There are also many methods in its // class in this namespace. If our namespace name is very long, when writing a program, we need to frequently enter a long complete path to call the method. // This is very troublesome. In this example, we use the using identifier, using system. This line of code tells the runtime environment which namespaces are used in our class, in this way, you can call system without entering the complete namespace + class name + method. console. writeline (); // you only need to enter the console. writeline ("Hello world! "); The console. writeline (" Hello world! ") ;}} Class helloworld
{Public static void main () {// you can see that the code is separated. This way, the compiler does not care about code segmentation, we can separate long code segments // to write our code system more clearly. console. writeline ("Hello world! ");}}