# OutlookCategoryCollection

Mutable Outlook category names with case-insensitive convenience operations.

Class 

`OfficeIMO.Email`

**Namespace**

`OfficeIMO.Email`

**Assembly**

`OfficeIMO.Email`

**Source revision**

`be6c300e4ab1` with working tree changes

**Source**

[OutlookCategoryCollection.cs:5](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L5)

**Implements**

`IList<string>` `ICollection<string>` `IEnumerable<string>` `IEnumerable`

**Modifiers**

sealed

**Attributes**

`DefaultMember("Item")`

Mutable Outlook category names with case-insensitive convenience operations.

## Inheritance

- object
- OutlookCategoryCollection

## Usage

Explore 1 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 1

- Property [EmailMessageMetadata.Categories](/api/email/officeimo-email-emailmessagemetadata/#property-categories)

Filter members 

Show inherited

## Constructors

`public OutlookCategoryCollection()` [#](#constructor-ctor)

[OutlookCategoryCollection.cs:5](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L5)

## Methods

`public void Add(string item)` [#](#method-add-string)

[OutlookCategoryCollection.cs:52](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L52)

Adds an item to the ICollection<T>.

Parameters

**item string required**

The object to add to the ICollection<T>.

Exceptions

- `NotSupportedException` – The ICollection<T> is read-only.

`public bool AddIfMissing(string category)` [#](#method-addifmissing-string)

[OutlookCategoryCollection.cs:10](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L10)

Adds a non-empty category unless an equivalent name already exists.

Parameters

**category string required**

Returns

`bool` true when the category was added.

`public void Clear()` [#](#method-clear)

[OutlookCategoryCollection.cs:55](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L55)

Removes all items from the ICollection<T>.

Exceptions

- `NotSupportedException` – The ICollection<T> is read-only.

Contains 2 overloads

`public bool Contains(string category, StringComparer comparer)` [#](#method-contains-string-stringcomparer)

[OutlookCategoryCollection.cs:41](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L41)

Returns whether the collection contains a category using the requested comparison.

Parameters

**category string required**

**comparer System.StringComparer required**

Returns

`bool`

`public bool Contains(string item)` [#](#method-contains-string)

[OutlookCategoryCollection.cs:58](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L58)

Determines whether the ICollection<T> contains a specific value.

Parameters

**item string required**

The object to locate in the ICollection<T>.

Returns

`bool` true if item is found in the ICollection<T>; otherwise, false.

`public void CopyTo(string[] array, int arrayIndex)` [#](#method-copyto-string-int32)

[OutlookCategoryCollection.cs:61](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L61)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

Parameters

**array string[] required**

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

**arrayIndex int required**

The zero-based index in array at which copying begins.

Exceptions

- `ArgumentNullException` – array is null.
- `ArgumentOutOfRangeException` – arrayIndex is less than 0.
- `ArgumentException` – The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

`public IEnumerator<string> GetEnumerator()` [#](#method-getenumerator)

[OutlookCategoryCollection.cs:47](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L47)

Returns an enumerator that iterates through the collection.

Returns

`IEnumerator<string>` An enumerator that can be used to iterate through the collection.

`public int IndexOf(string item)` [#](#method-indexof-string)

[OutlookCategoryCollection.cs:73](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L73)

Determines the index of a specific item in the IList<T>.

Parameters

**item string required**

The object to locate in the IList<T>.

Returns

`int` The index of item if found in the list; otherwise, -1.

`public void Insert(int index, string item)` [#](#method-insert-int32-string)

[OutlookCategoryCollection.cs:76](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L76)

Inserts an item to the IList<T> at the specified index.

Parameters

**index int required**

The zero-based index at which item should be inserted.

**item string required**

The object to insert into the IList<T>.

Exceptions

- `ArgumentOutOfRangeException` – index is not a valid index in the IList<T>.
- `NotSupportedException` – The IList<T> is read-only.

`public bool Remove(string item)` [#](#method-remove-string)

[OutlookCategoryCollection.cs:64](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L64)

Removes the first occurrence of a specific object from the ICollection<T>.

Parameters

**item string required**

The object to remove from the ICollection<T>.

Returns

`bool` true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

Exceptions

- `NotSupportedException` – The ICollection<T> is read-only.

`public int RemoveAll(string category)` [#](#method-removeall-string)

[OutlookCategoryCollection.cs:29](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L29)

Removes every category matching the supplied name case-insensitively.

Parameters

**category string required**

Returns

`int` The number of removed category entries.

`public void RemoveAt(int index)` [#](#method-removeat-int32)

[OutlookCategoryCollection.cs:79](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L79)

Removes the IList<T> item at the specified index.

Parameters

**index int required**

The zero-based index of the item to remove.

Exceptions

- `ArgumentOutOfRangeException` – index is not a valid index in the IList<T>.
- `NotSupportedException` – The IList<T> is read-only.

`public void ReplaceWith(IEnumerable<string> categories, bool removeDuplicates = true)` [#](#method-replacewith-collections-generic-ienumerable-system-string-boolean)

[OutlookCategoryCollection.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L18)

Replaces the collection, optionally removing case-insensitive duplicates.

Parameters

**categories System.Collections.Generic.IEnumerable<string> required**

**removeDuplicates bool = true optional**

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public int Count { get; }` [#](#property-count)

[OutlookCategoryCollection.cs:67](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L67)

Gets the number of elements contained in the ICollection<T>.

`public bool IsReadOnly { get; }` [#](#property-isreadonly)

[OutlookCategoryCollection.cs:70](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L70)

Gets a value indicating whether the ICollection<T> is read-only.

`public string this[int index] { get; set; }` [#](#property-item-int32)

[OutlookCategoryCollection.cs:83](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Outlook/OutlookCategoryCollection.cs#L83)

Gets or sets the element at the specified index.

Parameters

**index int required**

The zero-based index of the element to get or set.

Exceptions

- `ArgumentOutOfRangeException` – index is not a valid index in the IList<T>.
- `NotSupportedException` – The property is set and the IList<T> is read-only.

<!-- PowerForge markdown artifact sha256:66494FB1B9011053E87898732A4B86578699F0D398D8C2E292BD30B64381FD39 -->
