C # region command,

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.