> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with Collections

<Note>
  C# samples and information are applicable only to FRE for Windows.
</Note>

There are three major types of collections in ABBYY FineReader Engine:

* temporary collections (collections of references to existing objects)
* collections of child objects
* read-only collections of child objects

On this page, you can find information on the following:

* how to work with each type of collection

* how to view the list of all available collections

* how to work with collections in .NET in FRE for Windows

## Temporary collections

This type of collection represents a collection of references to existing objects. These are temporary collections; usually, they are used to pass various sets of parameters into methods that require them. You create this collection, add elements to it (elements are added as references to existing objects), pass to the required method, and then destroy the collection while the objects that were added to it remain. Such collections have Collection postfix in their names (e.g., StringsCollection, IntsCollection).

To work with a collection of such type:

1. Create the collection using the corresponding creation method of the [Engine](/fine-reader/engine/api-reference/engine-object-iengine-interface) object. For example, for the IntsCollection object, it is the [CreateIntsCollection](/fine-reader/engine/api-reference/engine-object-iengine-interface/creation-methods/createlessobjectgreater-methods) method. These collections can also be return values of some methods.
2. Add existing objects to the collection using its [Add](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/add-method) method. You can iterate through the collection using its read-only Count property, read-write [Element](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/element-property) property, and [Item](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/item-method) method. The first one gets the number of elements actually contained in the collection, the second and third ones provide access to the element at the specified index. The Element property allows you to access an element of the collection using the \[] operator in C#.
3. If necessary, modify the collection using other methods of the collection: [InsertAt](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/insertat-method), [DeleteAt](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/deleteat-method), [DeleteAll](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/deleteall-method) methods.
4. Pass the collection to the method that requires it as a parameter.

An example of using the IntsCollection object in C#:

<Accordion title="C# code">
  ```csharp theme={null}
   
  for( int i = 0; i < Document.Pages.Count; i++ )
  {
   if( Document.Pages[i].PageStructureOutOfDate )
   {
    pageIndices.Add( i );
   }
  }
  // Pass the created collection of page indices to a processing method
  if( pageIndices.Count > 0 || Document.DocumentStructureOutOfDate )
  {
   Document.SynthesizePages( pageIndices, null );
  }
  ```
</Accordion>

## Collections of child objects

Another type represents a collection of child objects of some parent object. These collections exist while their parent object exists. Via such collections, you can add or remove child objects of the parent object. When you add an element into the collection, a new object is created internally and then added to the collection. Examples of such collections: DictionaryDescriptions – a collection of dictionary description objects, BaseLanguages – a collection of base languages.

To use such collections:

1. Obtain the collection via the property of its parent object. For example, if you want to access the collection of base languages of a recognition language, use the [DictionaryDescriptions](/fine-reader/engine/api-reference/language-related-objects/baselanguage#dictionarydescriptions) property of the BaseLanguage object.
2. Iterate through the collection using the read-only Count and [Element](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/element-property) properties and the [Item](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/item-method) method. The first one gets the number of elements actually contained in the collection, the second and third ones get the element at the specified index. The Element property allows you to access an element of the collection using the \[] operator in C#.
3. If necessary, add new elements to the collection using its AddNew method. The AddNew methods of different collections can have slightly different syntax, but all these methods do the same: create a new collection element and add it into the collection. You can delete elements using the [DeleteAt](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/deleteat-method), [DeleteAll](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/deleteall-method) methods.

An example of working with the DictionaryDescriptions object in C#:

<Accordion title="C# code">
  ```csharp theme={null}
  FREngine.IEngine Engine = null;
  FREngine.IBaseLanguage baseLanguage = null;
  // Initialize Engine and obtain a base language of a text language
  ...
  // Get collection of dictionary descriptions of a base language and remove all items
  IDictionaryDescriptions dictionaryDescriptions = baseLanguage.DictionaryDescriptions;
  dictionaryDescriptions.DeleteAll();
  // Create a user dictionary description and add it to the collection
  IDictionaryDescription dictionaryDescription = dictionaryDescriptions.AddNew( DictionaryTypeEnum.DT_UserDictionary );
  ```
</Accordion>

## Read-only collections

Some collections of child objects are read-only. This means that they do not have editing methods, you can only iterate and view their elements. Examples of such collections are: PredefinedLanguages – a collection of predefined languages, Paragraphs – a collection of paragraphs of a text.

To view the elements of such collections:

1. Obtain the collection via the property of its parent object. For example, if you want to access the collection of paragraphs of a text, use the [Paragraphs](/fine-reader/engine/api-reference/text-related-objects/text#paragraphs) property of the Text object.
2. Iterate through the collection using the read-only Count and [Element](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/element-property) properties and the [Item](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/item-method) method. The first one gets the number of elements actually contained in the collection, the second and third ones get the element at the specified index. The Element property allows you to access an element of the collection using the \[] operator in C#.

An example of working with the Paragraphs object in C#:

<Accordion title="C# code">
  ```csharp theme={null}
  FREngine.IEngine Engine = null;
  FREngine.IBlock block = null;
  // Initialize Engine, recognize a document and obtain a text block of a layout
  ...
  FREngine.ITextBlock textBlock = block.GetAsTextBlock();
  // Iterate paragraphs of the text of the block
  int paragraphsCount = textBlock.Text.Paragraphs.Count;
  for (int iPar = 0; iPar < paragraphsCount; iPar++)
  {
   FREngine.IParagraph par = textBlock.Text.Paragraphs[iPar];
   string text = par.Text;
  }
  ```
</Accordion>

## All available collections

Below is the full list of the collections available in FineReader Engine. Some of the collections provide additional methods for working with elements. See details in the table below.

<table><thead><tr><th><p><strong>Collections of child objects</strong></p></th><th><p><strong>Read-only collections</strong></p></th><th><p><strong>Temporary collections</strong></p></th></tr></thead><tbody><tr><td><ul><li><strong><a href="/fine-reader/engine/api-reference/document-related-objects/authorslist">AuthorsList</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/language-related-objects/baselanguages">BaseLanguages</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/classification-related-objects/categories">Categories</a></strong> – this collection has an additional <strong>Find</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/layout-related-objects/checkmarkgroup">CheckmarkGroup</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/classification-related-objects/classificationobjects">ClassificationObjects</a></strong> – this collection has an additional <strong>Find</strong> method, while the <strong>AddNew</strong> method is replaced by the <strong>Add</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/language-related-objects/dictionarydescriptions">DictionaryDescriptions</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/document-related-objects/documentinformationdictionary">DocumentInformationDictionary</a></strong> – this collection is also a dictionary, therefore the <strong>Element</strong> property is replaced with the <strong>Value</strong> property.</li><li><strong><a href="/fine-reader/engine/api-reference/document-related-objects/frpages">FRPages</a></strong> – this collection of child objects differs from others of the same type. It does not have the <strong>AddNew</strong> method, instead you can use the <strong>AddPage</strong> method of the parent <strong>FRDocument</strong> object. It also does not have <strong>DeleteAll</strong> method and has additional <strong>IndexOf</strong>, <strong>Remove</strong> and <strong>Swap</strong> methods.</li><li><strong><a href="/fine-reader/engine/api-reference/layout-related-objects/layoutblocks">LayoutBlocks</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/text-related-objects/list">List</a></strong> – this collection does not have a <strong>DeleteAt </strong>method.</li><li><strong><a href="/fine-reader/engine/api-reference/document-related-objects/pdfattachments">PDFAttachments</a></strong> – this collection has the <strong>AddFromFile </strong>method<strong> </strong>and <strong>AddFromMemory</strong> (Windows) method instead of the <strong>AddNew</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/parameter-objects/export-parameters/pdfpictures">PDFPictures</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/layout-related-objects/separatorgroup">SeparatorGroup</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/layout-related-objects/tableseparators">TableSeparators</a></strong> – this collection has an additional <strong>IndexOf</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/text-related-objects/tabpositions">TabPositions</a></strong></li></ul></td><td><ul><li><strong><a href="/fine-reader/engine/api-reference/text-related-objects/barcodetext">BarcodeText</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/document-related-objects/businesscards">BusinessCards</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/document-comparison-objects/changes">Changes</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/text-related-objects/characterrecognitionvariants">CharacterRecognitionVariants</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/classification-related-objects/classificationresults">ClassificationResults</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/language-related-objects/detectedlanguages">DetectedLanguages</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/language-related-objects/fuzzystrings">FuzzyStrings</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/license-related-objects/licenses">Licenses</a></strong> – this collection has an additional <strong>Find</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/text-related-objects/paragraphlines">ParagraphLines</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/text-related-objects/paragraphs">Paragraphs</a></strong> – this collection has an additional <strong>IndexOf</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/language-related-objects/predefinedlanguages">PredefinedLanguages</a></strong> – this collection has an additional <strong>Find</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/mechanism-objects/scansources">ScanSources</a> (Windows)</strong></li><li><strong><a href="/fine-reader/engine/api-reference/supplementary-objects-and-methods/splitregions">SplitRegions</a></strong> – this collection has an additional <strong>GetSourcePageIndex</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/layout-related-objects/tablecells">TableCells</a></strong> – this collection has additional <strong>IndexOf</strong>, <strong>Merge</strong>, <strong>Split</strong> methods.</li><li><strong><a href="/fine-reader/engine/api-reference/classification-related-objects/trainingresults">TrainingResults</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/text-related-objects/wordrecognitionvariants">WordRecognitionVariants</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/text-related-objects/words">Words</a></strong></li></ul></td><td><ul><li><strong><a href="/fine-reader/engine/api-reference/supplementary-objects-and-methods/stringscollection">StringsCollection</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/supplementary-objects-and-methods/intscollection">IntsCollection</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/image-related-objects/officeconverters">OfficeConverters</a></strong> (Linux and Windows only) – This collection differs from all others in that it contains enumeration constants, not objects. It also has an additional <strong>Find</strong> method.</li><li><strong><a href="/fine-reader/engine/api-reference/image-related-objects/trainingimagescollection">TrainingImagesCollection</a></strong></li><li><strong><a href="/fine-reader/engine/api-reference/supplementary-objects-and-methods/regionscollection">RegionsCollection</a></strong></li><li><strong>Visual Components:</strong><ul><li><strong><a href="/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection">SpellWordCollection</a></strong></li><li><strong><a href="/fine-reader/engine/visual-components-reference/supplementary-objects/spellreplacementcollection">SpellReplacementCollection</a></strong></li><li><strong><a href="/fine-reader/engine/visual-components-reference/supplementary-objects/toolbar">Toolbar</a></strong> – this collection has additional <strong>Delete</strong>, <strong>Has</strong> methods.</li><li><strong><a href="/fine-reader/engine/visual-components-reference/supplementary-objects/popupmenu">PopupMenu</a></strong> – this collection has additional <strong>Delete</strong>, <strong>Has</strong> methods, <strong>CustomMenuEnabled</strong>, <strong>StandardMenuEnabled</strong> properties.</li></ul></li></ul></td></tr></tbody></table>

## Working with collections in .NET

All collection interfaces are derived from the IEnumerable interface. This means that you can use the foreach statement in C# (for each in Visual Basic) to manipulate collections. Note that working with collections using foreach has some specifics, e.g., enumerators cannot be used to modify the collection, but only to read the data in it. See remarks on [msdn.microsoft.com](http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.aspx).

An example of using foreach with the FRPages collection in C#:

<Accordion title="C# code">
  ```csharp theme={null}
  FREngine.IFRDocument document;
  // We presume that the document contains some pages
  ...
  foreach( FREngine.IFRPage page in document.Pages ) {
   // do something with the page
  }
  ```
</Accordion>
