C# Online! Chapter 3: Even C# is no exception! This is something newbies do!!
Friends who have played online games must know that the game At the beginning, novices will have something to do. It may be to fight the wooden man first, or talk to someone with an exclamation mark on their head, so that they can reach LV5 soon!! This kind of simple thing is right. For novices, the significance is very significant, from LV1 (nothing) ~ LV5 (it seems that there is still nothing…but the level is at least higher…), since novices have something to do, It must be the same for writing programs. Come and Bing!
“hello, world” This is the result of my query. This seems to be the beginning of writing programs. What must be done… and this is allusive, let’s see why everyone does this thing!
“hello, world”< /p>
refers to a computer program that only outputs the string “hello, world” (meaning “hello world!”) on the computer screen. Generally speaking, this is the most basic and simple program in every computer programming language, and it is usually the first program written by a beginner. It can also be used to determine whether the language’s compiler, program development environment, and execution environment have been installed properly.
The “hello, world” sample program first appeared in 1972 in the internal technical document “Introduction to the Language B” written by Brian Kernighan, a member of Bell Labs. The “Programming in C: A Tutorial” written by the same author in 1974 also continued to use this example; the “C Language Programming”, which was expanded and rewritten from this document, also retained this example program.
I understand! It seems that I have received the first task, which is to write “hello, world”! This will also be my first example program, if you are like me A completely newbie, and if you are afraid because we are about to start writing programs, please don’t be afraid, because I am more afraid than you…, but just write Program~ If you don’t write this example program, you won’t be able to increase the level!! Don’t be afraid! Let me look through my book first.
There is an example of this in the beginning of my book, and it is indeed the first lesson! Don’t say much, just follow me to see it!
STEP1
If you have read the first two articles of mine, you should already know what tools are needed to write C#, let’s open the development tools!! Then it is like (Figure 1) Create a new project, choose an application that can be written in C#, and remember to give your project a name.
(Picture 1)
After opening, we will see the program!! (The program finally appeared XD)
OK! Don’t be afraid, don’t be nervous, let’s take a look at what these programs are for! The following is what this program uses Keyword description:
There are two main uses of using :
-
As a demonstrative word, it is used To create aliases for namespaces, or to import types defined in other namespaces.
-
As a statement, at this time it is used to define a range, and the object will be disposed at the end of this range (Dispose).
Namespace :
Declare the name of the namespace, and connect the original program to be compiled in that namespace to After the statement. (So it is very clear… the name of the project, here is the name of the declaration namespace)
class :
The class is the use of class Keyword declaration.
static :
The static modifier (Modifier) can be used to declare static members. This member belongs to the type itself and does not belong to any object. The static modifier can be used for classes, fields, methods, properties, operators, events, and constructors, but cannot be used for indexers, destructors, or types other than classes.
string:
The string type represents a series of zero or more Unicode characters. String is the alias of String in the .NET Framework (Alias).
I have a general understanding. I believe that if you continue to study, you will become more and more familiar with the usage of these keywords! Continue our next task, let “hello, world” appear on our screen Let’s take a look at the next program:
STEP2
Let everyone know the same keywords that appear:
console:
The Console class provides basic support for applications that read and write symbols from the console.
Console.WriteLine () :
Write the current line ending character to the standard output data stream.
Console.ReadKey ():
Get the next character or function key pressed by the user. The pressed key will be displayed in the main console window.
Phew~ It should be done! Next, let’s see if it will actually be displayed on the screen! The legendary debug is about to appear (Figure 2) ~
(Picture 2)
After pressing down, you can see whether our mission is successful this time (Picture 3)!!
(Picture 3)
Did you see it! ? We can do it !!? It succeeded~ hello, world. Because ReadKey() is used at the end of the program, the ReadKey method will wait, that is, the thread that issued the ReadKey method will be blocked until the character or function key is pressed. You can use the symbol or function key in combination with one or more ALT, CTRL or SHIFT auxiliary keys. However, pressing the modifier key itself will not cause the ReadKey method to return. So in the window (Figure 3), as long as we press any key, the program will be closed.
This is the first example program, of course we can change it slightly!
It seems that my first mission is a great success!! Wow ha ha ha~ I don’t need to be a fan of my heart anymore! I should be able to increase the level after reporting it!
….., uh…well! I know I have to Keep working hard! Dear friends, please follow the above steps and do it together to complete this novice task!
This note: When starting a new project, you can use the hotkey CTRL+SHIFT+N , And when you want to debug, you can use the hotkey F5. Using more hotkeys can speed up the operation!
I hope that seniors like me or just want to learn C# For beginners, you can give me some suggestions and encouragement! Thank you~
(Related content in this article can be referred to and quoted from MSDN, wikipedia)
If this article is helpful to you, please help me click “I want to recommend“, click like, or帮我推到其他平台;您的鼓励将会是我继续努力的一大动力!!
若是有任何指教或是需要讨论之处,也不用客气,请在下面留言给我,我将会尽速回复~
Share | . . . . . . . . . .
原文:大专栏 C# Online ! 第三篇: Even C# is no exception! This is something novices have to do!!