VariableCollection Class

A collection of document variables.
Inheritance Hierarchy
SystemObject
  Aspose.WordsVariableCollection

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public class VariableCollection : IEnumerable<KeyValuePair<string, string>>, 
	IEnumerable

The VariableCollection type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleCount
Gets the number of elements contained in the collection.
Public propertyItemInt32
Gets or sets a document variable at the specified index. null values are not allowed as a right hand side of the assignment and will be replaced by empty string.
Public propertyItemString
Gets or a sets a document variable by the case-insensitive name. null values are not allowed as a right hand side of the assignment and will be replaced by empty string.
Methods
  NameDescription
Public methodCode exampleAdd
Adds a document variable to the collection.
Public methodCode exampleClear
Removes all elements from the collection.
Public methodCode exampleContains
Determines whether the collection contains a document variable with the given name.
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object that can be used to iterate over all variable in the collection.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleIndexOfKey
Returns the zero-based index of the specified document variable in the collection.
Public methodCode exampleRemove
Removes a document variable with the specified name from the collection.
Public methodCode exampleRemoveAt
Removes a document variable at the specified index.
Public methodToString (Inherited from Object.)
Remarks

Variable names and values are strings.

Variable names are case-insensitive.

Examples
Shows how to enumerate over document variables.
Document doc = new Document(MyDir + "Document.docx");

foreach (KeyValuePair<string, string> entry in doc.Variables)
{
    string name = entry.Key;
    string value = entry.Value;

    // Do something useful
    Console.WriteLine("Name: {0}, Value: {1}", name, value);
}
See Also