DateRangeCollection Class
Represents a collection of DateRange objects.
public class DateRangeCollection
- Inheritance:
- object object
Constructors
DateRangeCollection()
Initializes an instance of the class.
public DateRangeCollection()
Properties
Count
The number of DateRange items in the collection.
DayCount
The number of days contained in the collection.
IsReadOnly
Indicates whether the collection is read-only.
public bool IsReadOnly { get; }
Property Value
- bool:
trueif the collection is read-only; otherwise,false.
this[int]
The DateRange at the specified index.
Methods
Add(DateRange)
Adds a new DateRange item to the collection.
Clear()
Removes all items from the ICollection<T>.
public void Clear()
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The ICollection<T> is read-only. |
Contains(DateRange)
Returns whether the collection contains the specified DateRange item.
public bool Contains(DateRange item)
| Parameter | Type | Description |
|---|---|---|
| item | DateRange | The DateRange item for which to search. |
Returns
Contains(DateTime)
Returns whether the collection contains the specified DateTime.
public bool Contains(DateTime date)
| Parameter | Type | Description |
|---|---|---|
| date | DateTime | The DateTime for which to search. |
Returns
CopyTo(DateRange[], int)
Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.
public void CopyTo(DateRange[] array, int arrayIndex)
| Parameter | Type | Description |
|---|---|---|
| array | DateRange[] | The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing. |
| arrayIndex | int | The zero-based index in |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
| ArgumentException | The number of elements in the source ICollection<T> is greater than the available space from |
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<DateRange> GetEnumerator()
Returns
- IEnumerator<DateRange>:
An enumerator that can be used to iterate through the collection.
IndexOf(DateRange)
Searches for the specified DateRange and returns the zero-based index of the DateRange that contains it, if any.
public int IndexOf(DateRange item)
| Parameter | Type | Description |
|---|---|---|
| item | DateRange | The DateRange for which to search. |
Returns
IndexOf(DateTime)
Searches for the specified DateTime and returns the zero-based index of the DateRange that contains it, if any.
public int IndexOf(DateTime date)
| Parameter | Type | Description |
|---|---|---|
| date | DateTime | The DateTime for which to search. |
Returns
OverlapsWith(DateRange)
Determines whether the specified date range overlaps with, or crosses, any range in this collection.
public bool OverlapsWith(DateRange range)
| Parameter | Type | Description |
|---|---|---|
| range | DateRange | The date range to examine. |
Returns
- bool:
trueif the specified date range overlaps with, or crosses, any range in this collection; otherwisefalse.
Remove(DateRange)
Removes the specified DateRange item from the collection.
public bool Remove(DateRange item)
| Parameter | Type | Description |
|---|---|---|
| item | DateRange | The DateRange to remove. |
Returns
- bool:
trueif anything was removed; otherwise,false.
SetToMultipleDateRanges(IEnumerable<DateRange>)
Clears the collection, setting it to multiple DateRange items.
public void SetToMultipleDateRanges(IEnumerable<DateRange> items)
| Parameter | Type | Description |
|---|---|---|
| items | IEnumerable<DateRange> | The collection of DateRange items to add. |
SetToSingleDateRange(DateRange)
Clears the collection, setting it to a single DateRange.
public void SetToSingleDateRange(DateRange item)
| Parameter | Type | Description |
|---|---|---|
| item | DateRange | The DateRange containing the date range. |
ToString()
Returns the string representation of this object.
Events
CollectionChanged
Occurs when the collection changes.
public event NotifyCollectionChangedEventHandler? CollectionChanged
Event Type
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()