Skip to content

Commit e8d87d1

Browse files
Update _index.md
1 parent 8e6d355 commit e8d87d1

File tree

1 file changed

+1
-5
lines changed
  • content/english/net/working-with-fields/delete-fields

1 file changed

+1
-5
lines changed

content/english/net/working-with-fields/delete-fields/_index.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ Replace `"YOUR DOCUMENT DIRECTORY"` with the actual path to your document direct
6969
Iterate through all fields in the document and remove them:
7070

7171
```csharp
72-
for (int i = doc.Range.Fields.Count - 1; i >= 0; i--)
73-
{
74-
Field field = doc.Range.Fields[i];
75-
field.Remove();
76-
}
72+
doc.Range.Fields.ToList().ForEach(f => f.Remove());
7773
```
7874

7975
This loop iterates backwards through the fields collection to avoid issues with modifying the collection while iterating.

0 commit comments

Comments
 (0)