Skip to main content
A newer version of this page is available. .

How to: Add a Comment in the Start of a Section

  • 2 minutes to read

Follow the steps below.

  • Open the Editor | All Languages | Organize Members options page to configure the Member Organization rules feature.

    organize-members-page

  • Select a rule (for example, “Fields”).

  • Click the Comment button.

    comment-button

  • You can change the suggested comment name, for example, to “Fields…” in the corresponding text box. Press Enter to apply the new region name.

    comment-text-field

    CodeRush shows the “Member section name” field set to “Fields” in the right part of the options page.

    Note

    The “Member section name” field allows CodeRush to insert a comment into a template expansion. The template should contain the “MemberHeader” string provider with the “Fields”, “Methods”, or “Properties” argument, depending on the member type for which you want to add a comment. When you expand, for example, one of the “p?type?” templates (“pb”, “ps”, and others), CodeRush adds this comment to fields.

  • Click Apply to save changes or click OK to save changes and close the Organize Members options page.

  • Place the caret in a class member in the code snippet below:

namespace Ex
{
    public class TestClass
    {
        private int age;

        //Properties...
        public int Age { get { return age; } }
        public string Name { get { return name; } }

        private string name;
    }   
}
  • Press Ctrl+. or Ctrl+~ to invoke the Code Actions Menu.
  • Choose Organize Members from the menu and press Enter.

    add-comments-to-rule

CodeRush groups fields according to the Organize Members rules and creates the “Fields…” comment for fields.

See Also