Skip to content

Commit 2da2ae1

Browse files
Update how-to-insert-a-comment-into-a-word-processing-document.md
Change id calculation method
1 parent 2dcd36b commit 2da2ae1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

docs/how-to-insert-a-comment-into-a-word-processing-document.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ creates one using the [AddNewPart\<T\>()](https://msdn.microsoft.com/en-us/libra
115115
document.MainDocumentPart.WordprocessingCommentsPart.Comments;
116116
if (comments.HasChildren)
117117
{
118-
id = comments.Descendants<Comment>().Select(e => e.Id.Value).Max();
119-
var i = Int32.Parse(id);
120-
id = (++i).ToString();
118+
id = (comments.Descendants<Comment>().Select(e => int.Parse(e.Id.Value)).Max() + 1).ToString();
121119
}
122120
}
123121
else
@@ -280,9 +278,7 @@ Following is the complete sample code in both C\# and Visual Basic.
280278
if (comments.HasChildren)
281279
{
282280
// Obtain an unused ID.
283-
id = comments.Descendants<Comment>().Select(e => e.Id.Value).Max();
284-
var i = Int32.Parse(id);
285-
id = (++i).ToString();
281+
id = (comments.Descendants<Comment>().Select(e => int.Parse(e.Id.Value)).Max() + 1).ToString();
286282
}
287283
}
288284
else

0 commit comments

Comments
 (0)