VariableCollectionGetEnumerator Method

Returns an enumerator object that can be used to iterate over all variable in the collection.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()

Return Value

Type: IEnumeratorKeyValuePairString, String

Implements

IEnumerableTGetEnumerator
Examples
Shows how to obtain an enumerator from a collection of document variables and use it.
Document doc = new Document(MyDir + "Document.docx");

doc.Variables.Add("doc", "Word processing document");
doc.Variables.Add("docx", "Word processing document");
doc.Variables.Add("txt", "Plain text file");
doc.Variables.Add("bmp", "Image");
doc.Variables.Add("png", "Image");

using (IEnumerator<KeyValuePair<string, string>> enumerator = doc.Variables.GetEnumerator())
{
    while (enumerator.MoveNext())
    {
        KeyValuePair<string, string> de = enumerator.Current;
        Console.WriteLine("Name: {0}, Value: {1}", de.Key, de.Value);
    }
}
See Also