# Comments

DsWord allows you to add, delete, and modify comments in a Word document. Learn more about comments in DsWord docs.

## Content

A comment is a note or a type of annotation which is usually added to a document when a user wants to add remarks, notes, reminder, or a feedback to it. For instance, when multiple users work on the same document, it becomes easy for them to leave a note, remarks or feedback for each other’s reference.
In DsWord, comments are represented by the [Comment](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Comment.html) class. It allows you to modify the content and other properties of the comments, such as, author, date of the comment, etc. DsWord allows you to add or insert comments in a Word document using Add or Insert method of the [CommentCollection](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.CommentCollection.html) class respectively. In addition, it lets you add and delete the comment replies as well. You can use [Reply](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Comment.Reply.html) method of the **Comment** class to add a new comment as a reply into the comments collection and the [Delete](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Comment.Delete.html) method to delete it.
![Comments in a Word document](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/doccomments.png)

## Add Comments

To add comments in a document:

1. Access the content object on which you want to add a comment. For example, access the first paragraph.
2. Access the comment collection using [Comments](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.RangeBase.Comments.html) property of the [RangeBase](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.RangeBase.html) class.
3. Add a comment to the paragraph using [Add](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.CommentCollection.Add.html) method of the [CommentCollection](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.CommentCollection.html) class.

    ```csharp
    doc.Load("CommentInWord.docx");
    
    //Access the first paragraph
    Paragraph par = doc.Body.Sections.First.GetRange().Paragraphs[0];
    
    //Add comment
    Comment c=par.GetRange().Comments.Add("CommentByCode","GC");
    
    //Save the document
    doc.Save("AddComment.docx");
    ```

## Modify Comments

To modify a comment through code:

1. Access a comment from the comment collection using the **Comments** property. For example, access the first comment.
2. Get the property of the comment you want to modify. For example, access Author and Initials properties of the first comment.
3. Modify the value of the properties. For example, set value of the Author property to DsWordUser and Initials property to G.C.W.

    ```csharp
    doc.Load("AddComment.docx");
    
    //Access the first paragraph
    Paragraph par = doc.Body.Sections.First.GetRange().Paragraphs[0];
    
    //Modify the first comment's author and initials
    par.GetRange().Comments[0].Author = "DsWordUser";
    par.GetRange().Comments[0].Initials = "D.S.W";
    
    //Mark the comment reply as closed
    par.GetRange().Comments[0].Done = true;
    
    doc.Save("ModifiedComment.docx");
    ```

## Delete Comments

To delete a comment:

1. Access a comment from the comment collection using the **Comments** property. For example, access the fourth comment in the document.
2. Delete the comment using **Delete** method of the Comment class.

    ```csharp
    doc.Load("CommentInWord.docx");
    
    //Delete the second comment
    doc.Body.Comments[3].Delete();       
    doc.Save("DeleteComment.docx");
    ```

## Add Comment Reply

To add a reply on a comment:

1. Access a comment from the comment collection using the **Comments** property. For example, access the second comment.
2. Add a new comment in the comment collection as a reply for the accessed comment using **Reply** method of the Comment class.

    ```csharp
    doc.Load("CommentInWord.docx");
    
    //Add comment reply for the last comment in the document
    doc.Body.Comments.Last.Reply("Reply Comment", "John Doe");
    
    //Add a comment reply
    Comment cReply = c.Reply("Reply of the added comment", "JD");
    
    //Mark the comment reply as closed
    cReply.Done = true;
    
    //Save the document
    doc.Save("AddComment.docx");
    ```

## Delete Comment Reply

To delete a reply on the comment:

1. Access a reply comment using Replies property of the **Comment** class. For example, access first reply of the first comment.
2. Delete the comment reply using **Delete** method of the Comment class.

    ```csharp
    //Delete first comment's first reply
    doc.Body.Comments.First.Replies[0].Delete();
    
    doc.Save("DelComment.docx");
    ```

For more information on how implement comments using DsWord, see [DsWord sample browser](https://developer.mescius.com/documents-api-word/demos/basics/content/comments/code-cs).