C # region command,
Region Command
Sometimes, you may write dozens, hundreds, or even thousands of lines of code to fulfill a requirement.
When there are a large number of codes, even though you can use detailed comments to help you read them, it is not easy to tell what code is doing.
Therefore, C # adds a syntax format -- region, which is written as follows:
# Region description
// Code
# Endregion
Region and endregion must be written in pairs. That is to say, you cannot write only one region or only one endregion, and they all start with.
What are the benefits of doing so? After writing the code like this, you can fold the code between them, like this:
In this way, the code of a large segment can be folded to make the entire code easier to read.
Like the comments, the region and endregion commands do not participate in compilation.
That is to say, in the compiled exe file, there is no such command, it only exists in the source code, easy to read.
Console clear
Sometimes, when the program runs to a certain time, we need to clear all the current content in the console. At this time, we need to use the console clear command.
This command is simple. Use the following code:
Console. Clear (); // when the program runs this statement, the current content of the Console is cleared.
For example:
Console. Write ("Hello ");
Console. Clear (); // when the program runs this statement, the current content of the Console is cleared.
Console. Write ("World ");
After running the command, you can only see the World, because although the output is Hello, you have encountered the console clear command to clear the output.