DateRangeCollection Class
Represents a collection of DateRange objects.
public class DateRangeCollection
- Inheritance:
- object object
Constructors
DateRangeCollection()
Initializes a new instance of the DateRangeCollection struct.
public DateRangeCollection()
Properties
Count
Gets the number of DateRange items in the collection.
DayCount
Gets the number of days contained in the collection.
IsReadOnly
Gets whether the collection is read-only.
public bool IsReadOnly { get; }
Property Value
- bool:
true
if the collection is read-only; otherwise,false
.
this[int]
Gets the DateRange at the specified index.
Methods
Add(DateRange)
Adds a new DateRange item to the collection.
Clear()
Clears the collection.
public void Clear()
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 entire collection to a compatible one-dimensional Array
,
starting at the specified index of the target array.
public void CopyTo(DateRange[] array, int arrayIndex)
Parameter | Type | Description |
---|---|---|
array | DateRange[] | The one-dimensional |
arrayIndex | int | The zero-based index in |
GetEnumerator()
Retrieves an IEnumerator
object for the entire collection.
public IEnumerator<DateRange> GetEnumerator()
Returns
- IEnumerator<DateRange>:
An
IEnumerator
object for the entire collection
Remarks
Enumerators are intended to be used only to read data in the collection. Enumerators cannot be used to modify the underlying collection.
The enumerator does not have exclusive access to the collection.
When an enumerator is instantiated, it takes a snapshot of the current state of the collection.
If changes are made to the collection, such as adding, modifying or deleting elements, the
snapshot gets out of sync and the enumerator throws an InvalidOperationException
.
Two enumerators instantiated from the same collection at the same time can have
different snapshots of 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:
true
if 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:
true
if 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 a String
that represents the current Object
.
Events
CollectionChanged
Occurs when the collection has changed.
public event NotifyCollectionChangedEventHandler CollectionChanged