Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to write multiple lines of comment for one #region scope?

Seems this question hasn't been asked. If it duplicates, please give a comment.

That's said I have the #region comment in C# code.

#region if this comment is very long, can I divide the comment into multi-lines?

   // my code is here

#endregion

Is it possible to divide the #region comment into multi-lines like the bottom code ?

#region the comment is separated into
#region-2 two lines.

   // my code is here

#endregion
like image 738
Jeff T. Avatar asked Oct 27 '25 10:10

Jeff T.


1 Answers

I don't think long comments were the intended usage for the #region directive. When I think "region" I think things like "Private Members" or "Service Declarations" or "Overloaded Constructors" or a simple label of that nature.

If you have a long comment, I would instead include it at the top of the region, like this:

#region Some Region Name

    /**
     * Here is a decently lengthy comment which describes the
     * group of class members within the region.
     */

    /// <summary>
    /// A regular member's comment documentation.
    /// </summary>
    public int MyRegionProperty { get; set; }

    // etc...

#endregion

MSDN describes the part that comes after #region as a "name", not a comment. Names should be descriptive enough to identify what's in the region, nothing more.

like image 199
Cᴏʀʏ Avatar answered Oct 29 '25 00:10

Cᴏʀʏ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!