In This Article

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.

public int Count { get; }

Property Value

int

DayCount

The number of days contained in the collection.

public int DayCount { get; }

Property Value

int

IsReadOnly

Indicates whether the collection is read-only.

public bool IsReadOnly { get; }

Property Value

bool:

true if the collection is read-only; otherwise, false.

this[int]

The DateRange at the specified index.

public DateRange this[int index] { get; }
Parameter Type Description
index int

Property Value

DateRange

Methods

Add(DateRange)

Adds a new DateRange item to the collection.

public void Add(DateRange item)
Parameter Type Description
item DateRange

The DateRange to add.

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

bool:

true if the collection contains the specified DateRange item; otherwise, false.

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

bool:

true if the collection contains the specified DateTime; otherwise, false.

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 array at which copying begins.

Exceptions

Type Condition
ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

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

int:

The zero-based index of the DateRange that contains the specified DateRange, if found; otherwise -1.

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

int:

The zero-based index of the DateRange that contains the specified DateTime, if found; otherwise -1.

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; otherwise false.

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 the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

Events

CollectionChanged

Occurs when the collection changes.

public event NotifyCollectionChangedEventHandler? CollectionChanged

Event Type

NotifyCollectionChangedEventHandler

Inherited Members

Extension Methods