The overview of ecma c # language specialisation (1)

zhaozj2021-02-08  220

The overview of ucma c # language survial8. Language overview This clause is an extended information. C # (pronunciation "C Sharp") is a simple, energetic, object-oriented and type-safe programming language, which can be quickly accepted by C / C programmers. The goal of C # is to combine the efficient and C powerful function of the rapid development (RAD) language. The following sections describe the basic characteristics of this language. In the following sections, the rules and others of the language are exactly described in detail. This chapter will strive to clear all the contents of the cover. The reader has a preliminary impression and more easily read the remaining chapters.

8.1 Beginning the "Hello, World" written with C # is as follows:

Using system; class hello {static void main () {console.writeline ("Hello, World");}}

The source code of the C # can be stored in one or more text files used as the extension as the extension, such as "Hello.cs" of this example. You can compile this in the command line:

CSC Hello.cs

This operation will generate a Hello.exe. The result of the output is:

Hello, World

Let us start analysis from grammar:

Using System; Directly References System Namespace provided by Common Language Infrastructure (CLI). This namespace contains the Console class you want to use in the main method. Namespace provides a method of hierarchically organizational library members. "Using" unwell restrictions and you can use the members in the namespace of the SYSTEM. Console.Writeline in the program is System.Console.writeline abbreviation. System is a name space, console is a class defined in System, WriteLine is a Static method for this class.

· The main function is a member of the Hello class. Because it has a Static modifier, it does not exist in the Hello entity, but only within this class.

· The entry point of the program, that is, the program started, always a method of static method.

· "Hello, World" uses a class library. But the standard does not define the class library. In fact, the program references the class library provided by the CLI. It is very interesting that the C / C developer will feel that there are many things that have not appeared in the "Hello, World" program.

· There is no main method in the program. All methods and variables do not appear in a global range; but always included within the declaration of data types (such as classes and structures).

· There is no "::" or "->" operator in the program. "::" Not a C # operator, and "->" is only used in some special occasions (insecure code). C # program "." Segment the name domain, such as Console.Writeline.

· There is no need to use after C #, the order of the statement is no longer meaningful.

· C # does not use #include to introduce source code, no longer a text and abstraction. For example, the Console class can be written in C #.

转载请注明原文地址:https://www.9cbs.com/read-2848.html

New Post(0)