---
title: "Xóa trường C#"
---

Đôi khi cần phải xóa một trường khỏi tài liệu. Điều này có thể xảy ra khi nó cần được thay thế bằng một loại trường khác hoặc khi trường này không còn cần thiết trong tài liệu nữa. Ví dụ trường `TOC` khi lưu vào HTML.

Để xóa trường được chèn vào tài liệu bằng [DocumentBuilder](https://reference.aspose.com/words/net/aspose.words/documentbuilder/).[InsertField](https://reference.aspose.com/words/net/aspose.words/documentbuilder/insertfield/), hãy sử dụng đối tượng [Field](https://reference.aspose.com/words/net/aspose.words.fields/field/) được trả về, cung cấp phương thức [Remove](https://reference.aspose.com/words/net/aspose.words.fields/field/remove/) thuận tiện để dễ dàng xóa trường khỏi tài liệu.

Ví dụ mã sau đây cho biết cách xóa một trường khỏi tài liệu:

{{< gist "aspose-words-gists" "eacc4fc7407a98d683f3084bb86d58f7" "Examples-CSharp-Programming-Documents-Fields-RemoveField-RemoveField.cs" >}}

```

Bạn có thể tải xuống tệp mẫu của ví dụ này từ [Aspose.Words GitHub](https://github.com/aspose-words/Aspose.Words-for-.NET/blob/master/Examples/Data/Various%20fields.docx).

```
