2. Hello World console application

Source: Internet
Author: User

I. Hello World ConsoleProgramSource code

 
Using system; using system. collections. generic; using system. LINQ; using system. text; namespace helloworld {class program {static void main (string [] ARGs) {// output Hello World console. writeline ("Hello world! "); // Console. writeline (ARGs. Length); // console. Readline ();}}}

Ii. Hello WorldCodeAnalysis

1. Main

The main method is the entry point of the program, and the main is a static method residing in the class or structure, in which other methods are created and called. A c # console application can have only one main method.

Pay attention to the following points when declaring the main method:

(1) The main method is the entry point of the program, and the program control starts and ends in the method;

(2) The main method is declared inside the class or structure and must be a static method;

(3) The main method can have the void or Int return type;

 
Static VoidMain (String[] ARGs)
{
//...
}

Or

Static IntMain (String[] ARGs)
{
//...
Return 0;
}

(4) When declaring the main method, either parameters or parameters can be used;

(5) parameters can be read as command line parameters starting from 0.

2. Static

Use the static modifier to declare a type, rather than a static member of a specific object. Static modifiers can be used for classes, fields, methods, attributes, operators, events, and constructors, but cannot be used for indexers, destructor, or types other than classes (such as structures ).

(1) Static members cannot be referenced through instances and must be applied by type names;

(2) Instances of all classes share a copy of static fields;

(3) constants or type declarations are implicitly static members;

(4) You cannot use this to reference static methods or attribute accessors;

(5) All members of the static class must be static;

(6) A Class (including a static class) can have a static constructor that calls a static constructor at a certain time between the start of the program and the instantiation class.

3. Hello World source code

Helloworld

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.