C # Hello Word learning Notes

Source: Internet
Author: User
Tags versions


Introduction to C #

C # is an object-oriented, high-level programming language that is run on top of the. NET framework published by Microsoft.

C # is a secure, stable, simple, elegant, object-oriented programming language derived from C and C + +. It inherits the power of C and C + + and removes some of their complex features (for example, no macros and multiple inheritance is not allowed). C # integrates VB Simple visualization operation and C + + 's high operational efficiency, with its powerful operating ability, elegant grammatical style, innovative language features and convenient assembly-oriented programming support. The preferred language for net development.

Although the. NET Framework is running on the Windows operating system, there are some versions that run on other operating systems to choose from. Mono is an open source version of the. NET framework that contains a C # compiler and can run on a variety of operating systems, such as Linux and Mac OS versions.

Hello World

The only way to learn a new language is to use it to program. For starters, the first program that is written is almost identical: "Hello World" on the screen, with the professional saying "Hello World".

Here we'll write the classic Hello world. Please enter the following in the editor and click Submit.

Using System;
Namespace Helloworldapplication
{
Class HelloWorld
{
static void Main (string[] args)
{
/* My first C # program * *
Console.WriteLine ("Hello World");
}
}
}

Results

> Hello world!
> Hello world!

C # Program Structure
A C # program consists mainly of the following parts: A reference part of a namespace, a namespace declaration, a class, class method, Class attribute, a main method, a statement or an expression, a comment, and so on.

Just like the example in our previous section, the following code:

Using System; A reference to a namespace
namespace helloworldapplication//namespace declaration
{
Class HelloWorld//Class
{
static void Main (string[] args)//main method
{
/* My first C # program *//Comment statement
Console.WriteLine ("Hello World"); Print Statements
}
}
}

Description

The 1th line of the program is using System; The Using keyword is used to include the System namespace in your program. Programs typically have multiple using statements.
The 2nd line of the program namespace is a namespace declaration. A namespace is a collection of a series of classes. The Helloworldapplication namespace contains class HelloWorld.

The 4th line of the program class is the declaration of the class. The class HelloWorld contains the data and method declarations used by the program. A class typically contains multiple methods. Method defines the behavior of a class. Here, the HelloWorld class has only one main method.

The 4th line of the program class is the declaration of the class. The class HelloWorld contains the data and method declarations used by the program. A class typically contains multiple methods. Method defines the behavior of a class. Here, the HelloWorld class has only one main method.

The 6th line of the program defines the Main method, which is the entry point for all C # programs. The Main method describes what the class will do when it executes.
The 8th line of the program/*...*/is the annotation section of the program, and the part of//is also a comment that will be ignored by the compiler.
The Main method specifies its behavior by means of the statement Console.WriteLine ("Hello World").

WriteLine is a method that defines the console class in the System namespace. The statement displays the message "Hello, world!" on the screen.

Through the study of the above content, I believe that the students have a certain understanding of C # program, is not there is still not understand the problem, in the course of learning later we will talk about.

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.