In This Article

DateRangeCollection Class

Represents a collection of DateRange objects.

public class DateRangeCollection : ICollection<DateRange>, IEnumerable<DateRange>, IEnumerable, INotifyCollectionChanged
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.

public int Count { get; }

Property Value

Int32:

The number of DateRange items in the collection.

DayCount

Gets the number of days contained in the collection.

public int DayCount { get; }

Property Value

Int32:

The number of days contained in the collection.

IsReadOnly

Gets whether the collection is read-only.

public bool IsReadOnly { get; }

Property Value

Boolean:

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

Item[Int32]

Gets the DateRange at the specified index.

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

Property Value

DateRange:

The DateRange at the specified index

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()

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

Boolean:

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

Boolean:

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

CopyTo(DateRange[], Int32)

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 Array that is the destination of the elements copied from the collection. The Array must have zero-based indexing.

arrayIndex Int32

The zero-based index in array at which copying begins.

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

Int32:

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

Int32:

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

Boolean:

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

Boolean:

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.

public override string ToString()

Returns

String:

A String that represents the current Object.

Events

CollectionChanged

Occurs when the collection has changed.

public event NotifyCollectionChangedEventHandler CollectionChanged

Event Type

NotifyCollectionChangedEventHandler

Inherited Members