Class ListByte
List class for type Byte that has been automatically generated
public class ListByte
- Inheritance
-
ListByte
Constructors
ListByte()
Initializes a new instance of the System.Collections.Generic.List class that is empty and has the default initial capacity.
public ListByte()
ListByte(IEnumerable)
Initializes a new instance of the System.Collections.Generic.List class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.
public ListByte(IEnumerable collection)
Parameters
collection
IEnumerableThe collection whose elements are copied to the new list.
Exceptions
- ArgumentNullException
collection is null
ListByte(int)
Initializes a new instance of the System.Collections.Generic.List class that is empty and has the specified initial capacity.
public ListByte(int capacity)
Parameters
capacity
intThe number of elements that the new list can initially store.
Exceptions
- ArgumentOutOfRangeException
capacity is less than 0.
Properties
Capacity
Gets or sets the total number of elements the internal data structure can hold without resizing.
public int Capacity { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
System.Collections.Generic.List.Capacity is set to a value that is less than System.Collections.Generic.List.Count
Count
Gets the number of elements contained in the System.Collections.Generic.List
public int Count { get; }
Property Value
this[int]
Gets or sets the element at the specified index.
public byte this[int index] { get; set; }
Parameters
index
intThe zero-based index of the element to get or set.
Property Value
- byte
The element at the specified index.
Exceptions
- ArgumentOutOfRangeException
index is less than 0. -or- index is equal to or greater than System.Collections.Generic.List.Count.
Methods
Add(byte)
Adds an object to the end of the System.Collections.Generic.List.
public void Add(byte item)
Parameters
item
byteThe object to be added to the end of the System.Collections.Generic.List. The value can be null for reference types.
AddRange(IEnumerable)
Adds the elements of the specified collection to the end of the System.Collections.Generic.List.
public void AddRange(IEnumerable collection)
Parameters
collection
IEnumerableThe collection whose elements should be added to the end of the System.Collections.Generic.List. The collection itself cannot be null, but it can contain elements that are null, if type byte is a reference type.
Exceptions
- ArgumentNullException
collection is null.
Contains(byte)
Determines whether an element is in the System.Collections.Generic.List.
public bool Contains(byte item)
Parameters
item
byteThe object to locate in the System.Collections.Generic.List. The value can be null for reference types.
Returns
- bool
true if item is found in the System.Collections.Generic.List; otherwise, false.
CopyTo(byte[])
Copies the entire System.Collections.Generic.List to a compatible one-dimensional array, starting at the beginning of the target array.
public void CopyTo(byte[] array)
Parameters
array
byte[]The one-dimensional System.Array that is the destination of the elements copied from System.Collections.Generic.List. The System.Array must have zero-based indexing.
Exceptions
- ArgumentNullException
array is null.
- ArgumentException
The number of elements in the source System.Collections.Generic.List is greater than the number of elements that the destination array can contain.
CopyTo(byte[], int)
Copies the entire System.Collections.Generic.List to a compatible one-dimensional array, starting at the specified index of the target array.
public void CopyTo(byte[] array, int arrayIndex)
Parameters
array
byte[]The one-dimensional System.Array that is the destination of the elements copied from System.Collections.Generic.List. The System.Array must have zero-based indexing.
arrayIndex
intThe 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 System.Collections.Generic.List is greater than the available space from arrayIndex to the end of the destination array.
CopyTo(int, byte[], int, int)
Copies a range of elements from the System.Collections.Generic.List to a compatible one-dimensional array, starting at the specified index of the target array.
public void CopyTo(int index, byte[] array, int arrayIndex, int count)
Parameters
index
intThe zero-based index in the source System.Collections.Generic.List at which copying begins.
array
byte[]The one-dimensional System.Array that is the destination of the elements copied from System.Collections.Generic.List. The System.Array must have zero-based indexing.
arrayIndex
intThe zero-based index in array at which copying begins.
count
intThe number of elements to copy.
Exceptions
- ArgumentNullException
array is null.
- ArgumentOutOfRangeException
index is less than 0. -or- arrayIndex is less than 0. -or- count is less than 0.
- ArgumentException
index is equal to or greater than the System.Collections.Generic.List.Count of the source System.Collections.Generic.List. -or- The number of elements from index to the end of the source System.Collections.Generic.List is greater than the available space from arrayIndex to the end of the destination array.
GetEnumerator()
Returns an enumerator that iterates through the System.Collections.Generic.List.
public IEnumerator GetEnumerator()
Returns
- IEnumerator
A System.Collections.Generic.List.Enumerator for the System.Collections.Generic.List.
GetRange(int, int)
Creates a shallow copy of a range of elements in the source System.Collections.Generic.List.
public ListByte GetRange(int index, int count)
Parameters
index
intThe zero-based System.Collections.Generic.List index at which the range starts.
count
intThe number of elements in the range.
Returns
- ListByte
A shallow copy of a range of elements in the source System.Collections.Generic.List.
Exceptions
- ArgumentOutOfRangeException
index is less than 0. -or- count is less than 0.
- ArgumentException
index and count do not denote a valid range of elements in the System.Collections.Generic.List.
IndexOf(byte)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire System.Collections.Generic.List.
public int IndexOf(byte item)
Parameters
item
byteThe object to locate in the System.Collections.Generic.List. The value can be null for reference types.
Returns
- int
The zero-based index of the first occurrence of item within the entire System.Collections.Generic.List, if found; otherwise, -1.
IndexOf(byte, int)
Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the System.Collections.Generic.List that extends from the specified index to the last element.
public int IndexOf(byte item, int index)
Parameters
item
byteThe object to locate in the System.Collections.Generic.List. The value can be null for reference types.
index
intThe 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 item within the range of elements in the System.Collections.Generic.List that extends from index to the last element, if found; otherwise, -1.
Exceptions
- ArgumentOutOfRangeException
index is outside the range of valid indexes for the System.Collections.Generic.List.
IndexOf(byte, int, int)
Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the System.Collections.Generic.List that starts at the specified index and contains the specified number of elements.
public int IndexOf(byte item, int index, int count)
Parameters
item
byteThe object to locate in the System.Collections.Generic.List. The value can be null for reference types.
index
intThe zero-based starting index of the search. 0 (zero) is valid in an empty list.
count
intThe number of elements in the section to search.
Returns
- int
The zero-based index of the first occurrence of item within the range of elements in the System.Collections.Generic.List that starts at index and contains count number of elements, if found; otherwise, -1.
Exceptions
- ArgumentOutOfRangeException
index is outside the range of valid indexes for the System.Collections.Generic.List. -or- count is less than 0. -or- index and count do not specify a valid section in the System.Collections.Generic.List.
Insert(int, byte)
Inserts an element into the System.Collections.Generic.List at the specified index.
public void Insert(int index, byte item)
Parameters
index
intThe zero-based index at which item should be inserted.
item
byteThe object to insert. The value can be null for reference types.
Exceptions
- ArgumentOutOfRangeException
index is less than 0. -or- index is greater than System.Collections.Generic.List.Count.
InsertRange(int, IEnumerable)
Inserts the elements of a collection into the System.Collections.Generic.List at the specified index.
public void InsertRange(int index, IEnumerable collection)
Parameters
index
intThe zero-based index at which the new elements should be inserted.
collection
IEnumerableThe collection whose elements should be inserted into the System.Collections.Generic.List. The collection itself cannot be null, but it can contain elements that are null, if type byte is a reference type.
Exceptions
- ArgumentNullException
collection is null.
- ArgumentOutOfRangeException
index is less than 0. -or- index is greater than System.Collections.Generic.List.Count.
LastIndexOf(byte)
Searches for the specified object and returns the zero-based index of the last occurrence within the entire System.Collections.Generic.List.
public int LastIndexOf(byte item)
Parameters
item
byteThe object to locate in the System.Collections.Generic.List. The value can be null for reference types.
Returns
- int
The zero-based index of the last occurrence of item within the entire the System.Collections.Generic.List, if found; otherwise, -1.
LastIndexOf(byte, int)
Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the System.Collections.Generic.List that extends from the first element to the specified index.
public int LastIndexOf(byte item, int index)
Parameters
item
byteThe object to locate in the System.Collections.Generic.List. The value can be null for reference types.
index
intThe zero-based starting index of the backward search.
Returns
- int
The zero-based index of the last occurrence of item within the range of elements in the System.Collections.Generic.List that extends from the first element to index, if found; otherwise, -1.
Exceptions
- ArgumentOutOfRangeException
index is outside the range of valid indexes for the System.Collections.Generic.List.
LastIndexOf(byte, int, int)
Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the System.Collections.Generic.List that contains the specified number of elements and ends at the specified index.
public int LastIndexOf(byte item, int index, int count)
Parameters
item
byteThe object to locate in the System.Collections.Generic.List. The value can be null for reference types.
index
intThe zero-based starting index of the backward search.
count
intThe number of elements in the section to search.
Returns
- int
The zero-based index of the last occurrence of item within the range of elements in the System.Collections.Generic.List that contains count number of elements and ends at index, if found; otherwise, -1.
Exceptions
- ArgumentOutOfRangeException
index is outside the range of valid indexes for the System.Collections.Generic.List. -or- count is less than 0. -or- index and count do not specify a valid section in the System.Collections.Generic.List.
Remove(byte)
Removes the first occurrence of a specific object from the System.Collections.Generic.List.
public bool Remove(byte item)
Parameters
item
byteThe object to remove from the System.Collections.Generic.List. The value can be null for reference types.
Returns
- bool
true if item is successfully removed; otherwise, false. This method also returns false if item was not found in the System.Collections.Generic.List.
RemoveAt(int)
Removes the element at the specified index of the System.Collections.Generic.List.
public void RemoveAt(int index)
Parameters
index
intThe zero-based index of the element to remove.
RemoveRange(int, int)
Removes a range of elements from the System.Collections.Generic.List.
public void RemoveRange(int index, int count)
Parameters
index
intThe zero-based starting index of the range of elements to remove.
count
intThe number of elements to remove.
Exceptions
- ArgumentOutOfRangeException
index is less than 0. -or- count is less than 0.
- ArgumentException
index and count do not denote a valid range of elements in the System.Collections.Generic.List.
ToArray()
Copies the elements of the System.Collections.Generic.List to a new array.
public byte[] ToArray()
Returns
- byte[]
An array containing copies of the elements of the System.Collections.Generic.List.