Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Class ItemCollection<T>

Base class for collections used as values in properties.

Inheritance
System.Object
ItemCollection<T>
Implements
System.ICloneable
System.Collections.IList
System.Collections.ICollection
System.Collections.IEnumerable
System.Collections.Generic.IList<T>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
EPiServer.Data.Entity.IReadOnly<ItemCollection<T>>
EPiServer.Data.Entity.IReadOnly
Namespace: EPiServer.Commerce.SpecializedProperties
Assembly: EPiServer.Business.Commerce.dll
Version: 14.26.0
Syntax
public class ItemCollection<T> : Object, ICloneable, IList, ICollection, IEnumerable, IList<T>, ICollection<T>, IEnumerable<T>, IReadOnly<ItemCollection<T>>, IReadOnly where T : ICloneable
Type Parameters
Name Description
T

The item type.

Constructors

ItemCollection()

Initializes a new instance of the ItemCollection<T> class.

Declaration
public ItemCollection()

ItemCollection(IEnumerable<T>)

Initializes a new instance of the ItemCollection<T> class.

Declaration
public ItemCollection(IEnumerable<T> items)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> items

The items.

Exceptions
Type Condition
System.ArgumentNullException

items

Properties

Count

Gets the item count.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32

IsModified

Gets or sets a value indicating whether this instance is modified.

Declaration
public bool IsModified { get; set; }
Property Value
Type Description
System.Boolean

IsReadOnly

Gets a value indicating whether this instance is read only.

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean

Item[Int32]

Gets or sets the item at the specified index.

Declaration
public T this[int index] { get; set; }
Parameters
Type Name Description
System.Int32 index

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

Property Value
Type Description
T

Methods

Add(T)

Adds the specified item.

Declaration
public void Add(T item)
Parameters
Type Name Description
T item

The item.

Clear()

Clears this instance.

Declaration
public void Clear()

Clone()

Creates a new object that is a copy of the current instance.

Declaration
public object Clone()
Returns
Type Description
System.Object

A new object that is a copy of this instance.

Contains(T)

Determines whether an element is in the collection.

Declaration
public bool Contains(T item)
Parameters
Type Name Description
T item

The item.

Returns
Type Description
System.Boolean

true if the item is found otherwise, false.

CopyTo(T[], Int32)

Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.

Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type Name Description
T[] array

The one-dimensional System.Array that is the destination of the elements copied from collection. The System.Array must have zero-based indexing.

System.Int32 arrayIndex

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

CreateWritableClone()

Creates a writable clone of the current instance.

Declaration
public ItemCollection<T> CreateWritableClone()
Returns
Type Description
ItemCollection<T>

A new object that is a copy of this instance and that is writeable.

GetEnumerator()

Returns an enumerator that iterates through a collection.

Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<T>

An System.Collections.IEnumerator object that can be used to iterate through the collection.

IndexOf(T)

Gets the index of the item in the collection.

Declaration
public int IndexOf(T item)
Parameters
Type Name Description
T item

The item.

Returns
Type Description
System.Int32

The index of item if found in the collection; otherwise, -1.

Insert(Int32, T)

Inserts the item at the specified index.

Declaration
public void Insert(int index, T item)
Parameters
Type Name Description
System.Int32 index

The zero-based index.

T item

The item.

MakeReadOnly()

Makes the instance read only.

Declaration
public void MakeReadOnly()

Remove(T)

Removes the specified item.

Declaration
public bool Remove(T item)
Parameters
Type Name Description
T item

The item.

Returns
Type Description
System.Boolean

true if success; otherwise false

RemoveAt(Int32)

Removes the item at the specified index.

Declaration
public void RemoveAt(int index)
Parameters
Type Name Description
System.Int32 index

The zero-based index of the item to remove.

ThrowIfReadOnly()

Throws an exception if the instance is read only.

Declaration
protected void ThrowIfReadOnly()

ToString()

Gets a string representation of the items by joining them together, using a comma as a separator.

Declaration
public override string ToString()
Returns
Type Description
System.String

A comma separated string of the items in the collection.

Implements

System.ICloneable
System.Collections.IList
System.Collections.ICollection
System.Collections.IEnumerable
System.Collections.Generic.IList<>
System.Collections.Generic.ICollection<>
System.Collections.Generic.IEnumerable<>
EPiServer.Data.Entity.IReadOnly<>
EPiServer.Data.Entity.IReadOnly