What is the difference between /// and #region in c#?

后端 未结 8 1980
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 03:57

What is the difference between ///

and #region ...#endregion statements in c#? Which one the best?

相关标签:
8条回答
  • 2021-02-13 04:02

    A region is used to collapse a large area of code and the // is used to add notes without the computer reading it.

    #region your large code
    loads of code in this area.
    #endregion
    
    //This is just a note that the computer won't read.
    
    0 讨论(0)
  • 2021-02-13 04:07

    #region isn't a comment statement at all. It's for marking sections of code. /// is for documentation comments.

    0 讨论(0)
  • 2021-02-13 04:17

    /// is for XML comments while region in not for commenting but for grouping code section together.

    0 讨论(0)
  • 2021-02-13 04:19

    #region makes your code readable/maintainable/ more organized
    /// documents code!

    0 讨论(0)
  • 2021-02-13 04:19

    /// is used to insert XML Comments in your code. Xml comments allow you to build an output Xml file from you project: This file is later used by Visual Studio to show you intellisense tooltip with the comments you inserted. Moreover, you can use eit to build your own documentation. See here an article about how to build documentation from your source code Xml comments

    #region is used to organize your code. It is only useful within IDE which understand it (VS), allowing you to collapse or expand every region of code you define with #region/#endregion

    0 讨论(0)
  • 2021-02-13 04:25

    Completely different things, one is for commenting/documentation, the other for hiding code.

    XML Comments (///)

    #Region

    0 讨论(0)
提交回复
热议问题