C # concise tutorial (1)

zhaozj2021-02-17  72

C # concise tutorial (1)

Disclaimer: I am in translation, add some of my own opinions and some other comparisons, I hope you can make everyone understand more, understand more.

If you have any suggestions, please mail: efoxxx@263.net

By the way, the brother of "finding the C # compiler" in the expert clinic, how can I have not received the C # compiler you promised, urgent, and send me a busy busy, Thanks!

C # Introduction

This section explains C # and talks about how to write, compile your own first C # program on the command line.

◆ What is C #

C # is a programming language in Microsoft. Because it is derived from C and C #, it is powerful. It is as simple as VB. In addition, it is very similar to Java for network programming, which is still a bit a bit of Delphi. Microsoft claims that C # is the most appropriate language written .NET Framework application.

◆ Install .NET SDK

To run C # on your machine, the first step must be installed .NET SDK. You can install .NET SDK under Windows Me, Windows NT, or Windows 2000. It is recommended that you use Windows 2000. Once the operating system is selected, please install the following steps:

Install IE 5.5

Install Microsoft .NET Framework SDK. It is completely free, you can download it in the following link: Net Framework SDK.

After the installation is complete, you can find a text editor to write your code and save it as a file with .cs as an extension. Type the code below Notepad and save it to my.cs.

◆ C # compiler and editor

Microsoft released new platform .NET SDK Beta 1 Release, bundled C # command line compiler. You have to install .NET SDK to run the C # program. Install .NET SDK, you can write your C # program code in any text editor. Some three-party editors can be obtained on the market. Some of them are free.

◆ Write your first C # program

Just like writing your first C program, start writing your first C # program. Open the text editor and type the code below:

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

◆ Compile your first C # program

Now, compile your .cs file with your C # command line compiler. The C # compiler must have at least one parameter, namely the C # file name. Suppose your C # file name is myclass.cs, then the syntax of the command line is as follows:

CSC myclass.cs

C # command line compiler in your project's bin directory (binary file directory, generally used to make execution files, it is used under Linux). Execute this EXE file to see the result.

just now. Let's take a look at the source code.

The first line is:

Using system.

Why do you want using system? System is a name space (Namespace), which stores system classes. We are used in the program to display the console class of the program running results on the console, which is defined in this system namespace (SYSTEM NAMESPACE). So we have to write this way.

The next line is Class Myclass. Keyword Class is used to produce new classes in C #.

Class myclass {....}

Each class is another static void main () function. It is the entry of the C # program execution (this is the same as Java, of course, C, C also has the main function and corresponding) static void main () {Console.Writeline ("Hello, C # World!");}

Method for console

WriteLine

The role is to write text on the console.

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

New Post(0)