C # Getting Started sharing (ii) application of--visual Studio and C # basic syntax

Source: Internet
Author: User

Visual Studio is undoubtedly the best tool for C # developers, and it is Microsoft's official development Kit, which includes most of the tools needed throughout the software lifecycle, such as UML tools, code control tools, integrated development environment (IDE), and more. The target code is written for all Microsoft supported platforms, including Microsoft Windows, Windows Mobile, Windows CE,. NET Framework,. NET Compact framework, and Microsoft Silverlight and Windows Phone. The latest version is the version of Visual Studio 2015, based on the. NET Framework 4.5.2.

You can go to Microsoft's official website www.microsoft.com or vs's official website www.visualstudio.com to download and install, here no longer repeat. We recommend two very good web addresses developed and used by Visual Studio, one of the aforementioned www.visualstudio.com, which has the latest dynamic and official documentation tutorials for Visual Studio, The other is www.visualstudio1.com, although only in the URL add a 1, but the content is completely different, this has a lot of Visual Studio developed video tutorials, all aspects of it, can be free to watch, I believe it will be a great help to everyone's study.

OK, next we open visual Studio and start the first C # program. Create a new console application and enter the following code:

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceConsoleApplication18 {9     classMyfirstclassTen     { One         Static voidMain (string[] args) A         { -Console.WriteLine ("wo~"); - console.readline (); the             return; -         } -     } -}

Run the program, you will see the command box appears, the real content is wo~.

In the preceding code example, the first few lines of code are related to namespaces, and namespaces are the way in which related classes are grouped together. The namespace keyword declares a namespace that should be related to the class. Then all the code in the curly braces is
Considered to be in this namespace. The compiler finds classes in the namespace specified by the using statement that are not defined in the current namespace but are referenced in code.
The use directive is used because the following is a library class System,console. The using System statement allows this class to be abbreviated to the console (the System. Other classes in the namespace also resemble this). If not
Using, will be written System.Console.WriteLine ("wo~");
The standard System namespace contains the most commonly used. NET type. All of the work done in C # is dependent on. NET base class, it is important to recognize this, in this case we used the console class in the system name space to write to the console window. That is, there is no built-in keyword for input and output, but it is completely dependent. NET class.
All C # code must be included in a class. The declaration of a class includes the class keyword followed by a name and a pair of curly braces.
In this case, we only called the WriteLine method of the System.Console class and wrote a line of text to the console window. It is a static method that does not need to instantiate the console object before it is called.
Console.ReadLine () reads the user's input and adds this line of code to let the application wait for the user to press Enter and then exit the application. In Visual Studio 2013, the console window disappears.
Then call return to exit the method (because this is the main method, and so it exits the program). Void is specified in the method header, so there is no return value.
After a general understanding of C # Basic syntax, here is a detailed discussion of the various aspects of C #. Because there is no way to write important programs without variables and constants, you will first introduce C # variables, constants, and data types in the next blog post.

C # Getting Started sharing (ii) application of--visual Studio and C # basic syntax

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.