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

后端 未结 8 1915
隐瞒了意图╮
隐瞒了意图╮ 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:26

    /// -> can be used for some comments

    #region ...#endregion -> can be used to mark particular set of code to a region,easy to reffer

    #region MainMethod
    
            /// <summary>
            /// Comments
            /// </summary>
            static void Main()
            {
                //Your code
            } 
            #endregion
    
    0 讨论(0)
  • 2021-02-13 04:27
    /// <summary>
    /// Three forward slashes denote a documentation comment, which can be used in
    /// conjunction with documentation tooling to generate API documentation for
    /// your code.
    /// </summary>
    
    // two forward slashes denote a code comment, which you can use to provide
    // commentary within your code
    
    /*
    This style of comment is called a block comment, which can be used to easily
    comment out large blocks of text within your code
    */
    
    #region Some Region Name
    
    // the above region allows the developer to collapse/uncollapse everything
    // within it, as long as their IDE supports regions
    public void SomeMethod()
    {
    }
    
    #endregion
    
    0 讨论(0)
提交回复
热议问题