Two. Writing the first C # program (note, namespace, class, Main method, identifier, keyword, input, output statement,)

Source: Internet
Author: User

Review writing a console application with the goal of outputting "Hello World" on the console

1. The first step is to open the visual Studio 2012 above version (I use VS 2015), the following interface appears after opening

2. The second step, this time to create a new solution, the creation of a solution can be directly clicked on the new project, you can also click on the menu bar of the file, in the drop-down box to choose new options, there are projects, sites, team projects and other options, which is created by the console application, select Project, the following interface appears.

Choose the third console application, change the name, the figure of the trouble is called DOME02, the other people I have seen practice with the dome, according to the function of different in dome prefix name.

Select the location where your solution is stored, and then click the OK button. This creates a control application.

3. Step three, start writing code now.

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacedome02{ Public classProgram {//write the first C # program (note, namespace, class, Main method, identifier, keyword, input, output statement,)        /// <summary>        /// ///three slashes are multiline comments, typically used in front of a class///The Main method is the entry for the program, and the C # program must contain a main method in which you can create objects and///call other methods. You can use three modifiers to decorate the main method, which is public and static///void modifier Indicates that this method has no return value/// </summary>        Static voidMain (string[] args) {            //a double slash is a single-line comment that is used mainly on shorter statements            /*two slashes with two asterisks are long notes, which can be described using a lot of text .*/             /*The _hello here is an identifier, the first character of the identifier must be a letter or an underscore followed by a letter underscore or a number, and the identifier is case-sensitive. Keyword: A predefined reserved identifier that has special meaning to the compiler, which cannot be used as an identifier in a program, except for a keyword prefixed with the @ symbol, where string is a keyword*/            string_hello ="Hello World"; //Console.WriteLine is the output statement, followed by a newline character, and Conso.write does not add a newline characterConsole.Write (_hello); Console.WriteLine ("Hello World"); //input statement, line is followed by a newline characterConsole.ReadLine (); }    }}

4. Fourth step, click Start Run Program, "Hello World" appears. Review complete

Two. Writing the first C # program (note, namespace, class, Main method, identifier, keyword, input, output statement,)

Related Article

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.