SimpleReadOnlyCollection<T> Class
Provides a generic read-only collection.
public class SimpleReadOnlyCollection<T> : ReadOnlyCollection<T> where T : class
- Type Parameters:
-
T-The type of collection item.
- Inheritance:
- object ReadOnlyCollection<T> object
- Derived:
- DockContainerCollection DocumentWindowCollection TabbedMdiContainerCollection TabbedMdiWindowCollection ToolWindowCollection
Constructors
SimpleReadOnlyCollection()
Initializes an instance of the class.
public SimpleReadOnlyCollection()
SimpleReadOnlyCollection(List<T>)
Initializes an instance of the class as a wrapper for the specified list.
protected SimpleReadOnlyCollection(List<T> list)
| Parameter | Type | Description |
|---|---|---|
| list | List<T> |
Properties
DefaultComparer
Defines the default comparer to be used when sorting. If an explicit default is not defined, an implicit default will be used.
Methods
FindIndex(int, int, Predicate<T>)
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the List<T> that starts at the specified index and contains the specified number of elements.
public int FindIndex(int startIndex, int count, Predicate<T> match)
| Parameter | Type | Description |
|---|---|---|
| startIndex | int | The zero-based starting index of the search. |
| count | int | The number of elements in the section to search. |
| match | Predicate<T> | The Predicate<T> delegate that defines the conditions of the element to search for. |
Returns
- int:
The zero-based index of the first occurrence of an element that matches the conditions defined by
match, if found; otherwise, -1.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
-or-
-or-
|
FindIndex(int, Predicate<T>)
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the List<T> that extends from the specified index to the last element.
public int FindIndex(int startIndex, Predicate<T> match)
| Parameter | Type | Description |
|---|---|---|
| startIndex | int | The zero-based starting index of the search. |
| match | Predicate<T> | The Predicate<T> delegate that defines the conditions of the element to search for. |
Returns
- int:
The zero-based index of the first occurrence of an element that matches the conditions defined by
match, if found; otherwise, -1.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
FindIndex(Predicate<T>)
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire List<T>.
public int FindIndex(Predicate<T> match)
| Parameter | Type | Description |
|---|---|---|
| match | Predicate<T> | The Predicate<T> delegate that defines the conditions of the element to search for. |
Returns
- int:
The zero-based index of the first occurrence of an element that matches the conditions defined by
match, if found; otherwise, -1.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
FindLastIndex(int, int, Predicate<T>)
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the List<T> that contains the specified number of elements and ends at the specified index.
public int FindLastIndex(int startIndex, int count, Predicate<T> match)
| Parameter | Type | Description |
|---|---|---|
| startIndex | int | The zero-based starting index of the backward search. |
| count | int | The number of elements in the section to search. |
| match | Predicate<T> | The Predicate<T> delegate that defines the conditions of the element to search for. |
Returns
- int:
The zero-based index of the last occurrence of an element that matches the conditions defined by
match, if found; otherwise, -1.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
-or-
-or-
|
FindLastIndex(int, Predicate<T>)
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the List<T> that extends from the first element to the specified index.
public int FindLastIndex(int startIndex, Predicate<T> match)
| Parameter | Type | Description |
|---|---|---|
| startIndex | int | The zero-based starting index of the backward search. |
| match | Predicate<T> | The Predicate<T> delegate that defines the conditions of the element to search for. |
Returns
- int:
The zero-based index of the last occurrence of an element that matches the conditions defined by
match, if found; otherwise, -1.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
ForEach(Action<T>)
Performs the specified action on each element of the List<T>.
public void ForEach(Action<T> action)
| Parameter | Type | Description |
|---|---|---|
| action | Action<T> | The Action<T> delegate to perform on each element of the List<T>. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| InvalidOperationException | An element in the collection has been modified. |
IndexOf(T, int)
Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the List<T> that extends from the specified index to the last element.
public int IndexOf(T item, int index)
| Parameter | Type | Description |
|---|---|---|
| item | T | The object to locate in the List<T>. The value can be |
| index | int | The zero-based starting index of the search. 0 (zero) is valid in an empty list. |
Returns
- int:
The zero-based index of the first occurrence of
itemwithin the range of elements in the List<T> that extends fromindexto the last element, if found; otherwise, -1.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
IndexOf(T, int, int)
Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the List<T> that starts at the specified index and contains the specified number of elements.
public int IndexOf(T item, int index, int count)
| Parameter | Type | Description |
|---|---|---|
| item | T | The object to locate in the List<T>. The value can be |
| index | int | The zero-based starting index of the search. 0 (zero) is valid in an empty list. |
| count | int | The number of elements in the section to search. |
Returns
- int:
The zero-based index of the first occurrence of
itemwithin the range of elements in the List<T> that starts atindexand containscountnumber of elements, if found; otherwise, -1.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
-or-
-or-
|
LastIndexOf(T)
Searches for the specified object and returns the zero-based index of the last occurrence within the entire List<T>.
public int LastIndexOf(T item)
| Parameter | Type | Description |
|---|---|---|
| item | T | The object to locate in the List<T>. The value can be |
Returns
LastIndexOf(T, int)
Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the List<T> that extends from the first element to the specified index.
public int LastIndexOf(T item, int index)
| Parameter | Type | Description |
|---|---|---|
| item | T | The object to locate in the List<T>. The value can be |
| index | int | The zero-based starting index of the backward search. |
Returns
- int:
The zero-based index of the last occurrence of
itemwithin the range of elements in the List<T> that extends from the first element toindex, if found; otherwise, -1.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
Sort()
Sorts the elements in the entire List<T> using the default comparer.
public void Sort()
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The default comparer Default cannot find an implementation of the IComparable<T> generic interface or the IComparable interface for type |
Sort(IComparer<T>)
Sorts the elements in the entire List<T> using the specified comparer.
public void Sort(IComparer<T> comparer)
| Parameter | Type | Description |
|---|---|---|
| comparer | IComparer<T> | The IComparer<T> implementation to use when comparing elements, or |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
|
| ArgumentException | The implementation of |
Sort(Comparison<T>)
Sorts the elements in the entire List<T> using the specified Comparison<T>.
public void Sort(Comparison<T> comparison)
| Parameter | Type | Description |
|---|---|---|
| comparison | Comparison<T> | The Comparison<T> to use when comparing elements. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException | The implementation of |
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()