## FieldPrivate class

Implements the PRIVATE field.

To learn more, visit the [Working with Fields](https://docs.aspose.com/words/net/working-with-fields/) documentation article.

```csharp
public class FieldPrivate : Field
```

## Constructors

| Name | Description |
| --- | --- |
| [FieldPrivate](fieldprivate/)() | The default constructor. |

## Properties

| Name | Description |
| --- | --- |
| [DisplayResult](../../aspose.words.fields/field/displayresult/) { get; } | Gets the text that represents the displayed field result. |
| [End](../../aspose.words.fields/field/end/) { get; } | Gets the node that represents the field end. |
| [Format](../../aspose.words.fields/field/format/) { get; } | Gets a [`FieldFormat`](../fieldformat/) object that provides typed access to field's formatting. |
| [IsDirty](../../aspose.words.fields/field/isdirty/) { get; set; } | Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document. |
| [IsLocked](../../aspose.words.fields/field/islocked/) { get; set; } | Gets or sets whether the field is locked (should not recalculate its result). |
| [LocaleId](../../aspose.words.fields/field/localeid/) { get; set; } | Gets or sets the LCID of the field. |
| [Result](../../aspose.words.fields/field/result/) { get; set; } | Gets or sets text that is between the field separator and field end. |
| [Separator](../../aspose.words.fields/field/separator/) { get; } | Gets the node that represents the field separator. Can be `null`. |
| [Start](../../aspose.words.fields/field/start/) { get; } | Gets the node that represents the start of the field. |
| virtual [Type](../../aspose.words.fields/field/type/) { get; } | Gets the Microsoft Word field type. |

## Methods

| Name | Description |
| --- | --- |
| [GetFieldCode](../../aspose.words.fields/field/getfieldcode/)() | Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included. |
| [GetFieldCode](../../aspose.words.fields/field/getfieldcode/)(*bool*) | Returns text between field start and field separator (or field end if there is no separator). |
| virtual [Remove](../../aspose.words.fields/field/remove/)() | Removes the field from the document. Returns a node right after the field. If the field's end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns `null`. |
| [Unlink](../../aspose.words.fields/field/unlink/)() | Performs the field unlink. |
| [Update](../../aspose.words.fields/field/update/)() | Performs the field update. Throws if the field is being updated already. |
| [Update](../../aspose.words.fields/field/update/)(*bool*) | Performs a field update. Throws if the field is being updated already. |

## Remarks

Provides a private storage area. This field is used to store data for documents converted from other file formats.

## Examples

Shows how to process PRIVATE fields.

```csharp
// Open a Corel WordPerfect document which we have converted to .docx format.
Document doc = new Document(MyDir + "Field sample - PRIVATE.docx");

// WordPerfect 5.x/6.x documents like the one we have loaded may contain PRIVATE fields.
// Microsoft Word preserves PRIVATE fields during load/save operations,
// but provides no functionality for them.
FieldPrivate field = (FieldPrivate)doc.Range.Fields[0];

Assert.That(field.GetFieldCode(), Is.EqualTo(" PRIVATE \"My value\" "));
Assert.That(field.Type, Is.EqualTo(FieldType.FieldPrivate));

// We can also insert PRIVATE fields using a document builder.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertField(FieldType.FieldPrivate, true);

// These fields are not a viable way of protecting sensitive information.
// Unless backward compatibility with older versions of WordPerfect is essential,
// we can safely remove these fields. We can do this using a DocumentVisiitor implementation.
Assert.That(doc.Range.Fields.Count, Is.EqualTo(2));

FieldPrivateRemover remover = new FieldPrivateRemover();
doc.Accept(remover);

Assert.That(remover.GetFieldsRemovedCount(), Is.EqualTo(2));
Assert.That(doc.Range.Fields.Count, Is.EqualTo(0));
```

Shows how to process PRIVATE fields (FieldPrivateRemover).

```csharp
/// <summary>
/// Removes all encountered PRIVATE fields.
/// </summary>
public class FieldPrivateRemover : DocumentVisitor
{
    public FieldPrivateRemover()
    {
        mFieldsRemovedCount = 0;
    }

    public int GetFieldsRemovedCount()
    {
        return mFieldsRemovedCount;
    }

    /// <summary>
    /// Called when a FieldEnd node is encountered in the document.
    /// If the node belongs to a PRIVATE field, the entire field is removed.
    /// </summary>
    public override VisitorAction VisitFieldEnd(FieldEnd fieldEnd)
    {
        if (fieldEnd.FieldType == FieldType.FieldPrivate)
        {
            fieldEnd.GetField().Remove();
            mFieldsRemovedCount++;
        }

        return VisitorAction.Continue;
    }

    private int mFieldsRemovedCount;
}
```

### See Also

* class [Field](../field/)
* namespace [Aspose.Words.Fields](../../aspose.words.fields/)
* assembly [Aspose.Words](../../)
