FieldGetFieldCode Method (Boolean)

Returns text between field start and field separator (or field end if there is no separator).

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public string GetFieldCode(
	bool includeChildFieldCodes
)

Parameters

includeChildFieldCodes
Type: SystemBoolean
True if child field codes should be included.

Return Value

Type: String
Examples
Shows how to get text between field start and field separator (or field end if there is no separator).
Document doc = new Document(MyDir + "Nested fields.docx");

foreach (Field field in doc.Range.Fields)
{
    if (field.Type == FieldType.FieldIf)
    {
        FieldIf fieldIf = (FieldIf)field;

        string fieldCode = fieldIf.GetFieldCode();

        if (containsNestedFields)
        {
            fieldCode = fieldIf.GetFieldCode(true);
        }
        else
        {
            fieldCode = fieldIf.GetFieldCode(false);
        }
    }
}
See Also