C # Series 1 C # opening introduction

Source: Internet
Author: User

1. C # Introduction

C # is. NET platform is a customized object-oriented language, which is similar to Java in C ++ evolution (extract the advantages of C ++, abandon some underlying operations that plague developers. the main language C # Of the NET platform also draws on some features of other languages, such as VB6 class attributes.

C # is like a mix of C ++, Java, VB6, and these languages. It absorbs the essence of multiple languages. Let's take a look at the advantages of C:

1. C # is a fully object-oriented language. Using the object-oriented ideology, we can use the real-world thing model to describe the development model of our computer software, making our code more organized, better division of labor and maintenance.

2. C # discards pointers in C ++, greatly reducing the complexity of program development. In addition, it also provides a garbage collector to manage memory, programmers do not need to use the delete keyword of C ++ to destroy the memory. You do not need to worry about memory release to reduce the development complexity.

3. Supports interface-based programming technology to implement loosely coupled systems and facilitate software upgrade and expansion in the future. Let's just list it!

 

2. My first C # Program

You guessed it. Is Hello World. Okay. Open Microsoft Visual Studio (available version ).

Step 1: click File> New> Project in the upper left corner.

Step 2: Select Visual C #-> console application-> name MyHelloWorld from the tree menu on the left of the pop-up dialog box.

 

Step 3: type the following code in the editing area:

My first program HelloWorld 1  Using System;

3  Namespace MyHelloWorld
4  {
5  Class Program
6  {
7  Static   Void Main ( String [] Args)
8  {
9  Console. WriteLine ( " Hello World... " );
10  }
11  }
12  }

 

 

Step 4: Run Ctrl + F5. The running effect is as follows:

In this way, the console outputs a sentence: Hello World... so our first program is complete. Next, let's take a preliminary look at it.

 

3.Preliminary analysis of my first C # Program 

1. First, let's look at the first line of code:

Using System;

 

This line of code imports the namespace named system. Now you will ask, what is a namespace?

Namespace: a namespace is a group of the relevant types in a local communications administration. <From C # And. NET 3.0 advanced programming>

For example:

For example, pens and computers all belong to office supplies, MP4 game machines, and so on. Well, now I need to write a program. At this time, I need office supplies. At this time, I need to take my office supplies, use as needed (for example, use a notebook for programming ). At this time, taking my office supplies is an import action, and office supplies are namespace. After work is complete, I need to play games. We can use our entertainment products, at this time, we imported a namespace named entertainment products. It includes MP4 game consoles and so on.

The Code is as follows:

Using Office supplies;
Using Entertainment products;

 

2. Read the following code after understanding the namespace

Namespace in the third line MyHelloWorld // define your own namespace

After understanding the namespace, the third one is easy to understand. It is to define your own namespace and tell others the type of your namespace packaging in the future.

 

Class Program // is your application class

Static   Void Main ( String [] Args) // entry point of the program

Now you can understand program as your program. The Main () method is the entry point of your program. When the program runs, you will find Main () (entry point) method to execute the code.

 

In the entry point method, the Console. WriteLine ("Hello World...");As follows:

Console. WriteLine ( " Hello World... " );

It means to output a sentence in the console: Hello world...

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.