Beginner with c #

zhaozj2021-02-08  218

/ * if you want to read the e Edition, Here is the link (http://msdn.microsoft.com/vstudio/nextgen/technology/clangref.doc).

i translated it with my ingotion (kamphkb@yeah.net). Thank you!

1 Introduction C # is a profile language that is simple, fashionable (?), Object orientation (type-way). It (pronunciation: c sharp) is developed from C / C (? I feel more like Java), and C / C is a language. So, it is easy to accept C / C programmers. The goal of C # is to combine the high yield and C functions of Visual Basic. C # will be a molecule of VS7. VS7 also supports VB, VC, and Markup - Vbscript and JScript. All of these languages ​​are supported in Next Generation Windows Services (NWGS) Platform (C # requires a NWGS SDK package, you can download on the M $ website). With this stuff, C # does not need your own class library, and use some mature libraries such as VC or VB. C # also does not have your own class library. After the talents were finished. 1.1 An example of an old earth (can not change it?) * / / * IdontlikeHelloWorld.cs: Such a out sample :( * / 1: using system; 2: class idontlikeHelloWorld 3: {4: static void main ) {5: Console.Writeline ("I DONT LIKE Hello World"); 6: console.readline (); 7:} 8:} / * If you want to go out, you will consider the example of change a better point. ^ & ^ Let's talk about how to run. First, you need windows2000! (Yes, it is it, please don't lose the skin anywhere - the whole banana will lose it.) Then, need NWGS SDK! (82.4MB, no Very big. Oh, I have no my own class.) After installation, type in the directory where your program is located: CSC idontlikeHelloWorld.cs (plus a Enter button) Is it a bit retro taste? This operation Will generate an idontlikeHelloWorld.exe file in the same directory as you * .cs. Double-click it, you can see: I DONT LIKE Hello World Enter to end it, very simple. However, you can do this: The suffix is ​​better (ie: idontlikeHelloWorld.c). This can be typed with VC's IDE, editing .vc txt Editor is the best 噢 (also vc, no !!!). Then: then: then: CSC idontlikeHelloWorld.c (coupled with a Enter key) The final effect is exactly the same. Ok, now analyze the syntax: (C # is completely uninterested: - |) 1: using system; using is actually the keyword of C , The meaning in C # also is also imitation (that is, I don't dare 100% affirmation, sorry) .using is used after another keyword Namespace. Still look at Namespace.

Syntax: (from msdn) Namespace [Identifier] {namespace-body} 俺 understand: Identifier: SystemTem (remember: C # and C / C , is case sensitive!). SYSTEM must be unique within the range of using it. That is, there is no second SYSTEM, but there may be System. And "its range", I don't want to explain in detail, only in practice can be mastered. Moreover, beginners don't have to know at all! I have recently known that there is also a namespace and using. :) In {Namespace-body} is the true useful stuff, including the declaration and definition of the "console.writeline" of the fifth line (will be mentioned later). System is defined by NWGS, we only need it (use) it. As for the definition of SYSTEM, don't take it! Hand it to the compiler (that is, the "csc.exe") is looking for. This replaces "#include" in C / C , it can be said to be a step and avoid a lot of annoying details. If you haven't learned C / C , you don't have to pay attention. Namespace will talk later. 2: Class IDontlikeHelloWorld Class: It is another keyword "class" in the C language. Represents a series of features (official statements: attributes) and behavioral methods, with its own procedures "alternative, create and different" Dongdong! Here, I define "idontlikehelloworld". Note: This is also C # enforce, both of which must be performed for each executable program. If you want to do things, you can record a pair of curly brackets behind the Class you define. Note: "{" and "}" correspondence, "(" and ")". 4: static void main () {main () is the first action (behavioral method) of this example, the first thing to do. It is a way to be a defined iDontlikeHelloWorld class. And it is C # to force, is the truly start of the program! The order in "{}" immediately followed in it is the running order of the program! In this case, only one line (why you can use it? You can remove it again), output a sentence. 5: Console.Writeline ("I DONT LIKE Hello World"); very strange, console (reminder again: pay attention to case) is not defined, from you? It is actually a class belonging to System Namespace. WriteLine () is a method in the Console class to display a sentence (string). Here is just 1/18 of this method! And is the simplest! Other have the opportunity to say. You can also search for "console.writeline" in "console.writeline" in "NGWS SDK Documentaion", remember to check "Search Only Title", it will list 19 items.

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

New Post(0)