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

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
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
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object that can be used to iterate over all variable in the collection.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Public methodCode exampleIndexOfKey
Returns the zero-based index of the specified document variable in the collection.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
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
Returns a string that represents the current object.
(Inherited from Object.)
Remarks

Variable names and values are strings.

Variable names are case-insensitive.

Examples
Shows how to enumerate over document variables.
[C#]

Document doc = new Document(MyDir + "Document.doc");

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