Struct Interval
An interval between two instants in time (start and end). The interval include the start instant and excludes
the end instant. The end may equal the start (resulting in an empty interval), but will not be before the start.
Since 1.4.x
Availability net35-Client
Implements
IEquatable<Interval>
Inherited Members
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetType()
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
public struct Interval : IEquatable<Interval>
Constructors
Interval(Instant, Instant)
Initializes a new instance of the Interval struct.
The interval includes the
start
instant and excludes the
end
instant. The end may equal the start (resulting in an empty interval), but must not be before the start.
Since 1.4.x
Availability net35-Client
Declaration
public Interval(Instant start, Instant end)
Parameters
Type | Name | Description |
---|---|---|
Instant | start | The start Instant. |
Instant | end | The end Instant. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | end is earlier than start . |
Properties
Duration
Returns the duration of the interval.
Since 1.4.x
Availability net35-Client
Declaration
public Duration Duration { get; }
Property Value
Type | Description |
---|---|
Duration | The duration of the interval. |
Remarks
This will always be a non-negative duration, though it may be zero.
End
Gets the end instant.
Since 1.4.x
Availability net35-Client
Declaration
public Instant End { get; }
Property Value
Type | Description |
---|---|
Instant | The end Instant. |
Remarks
This will never be earlier than Start, though it may be equal to it.
Start
Gets the start instant.
Since 1.4.x
Availability net35-Client
Declaration
public Instant Start { get; }
Property Value
Type | Description |
---|---|
Instant | The start Instant. |
Remarks
This will never be later than End, though it may be equal to it.
Methods
Equals(Interval)
Indicates whether the value of this interval is equal to the value of the specified interval.
Since 1.4.x
Availability net35-Client
Declaration
public bool Equals(Interval other)
Parameters
Type | Name | Description |
---|---|---|
Interval | other | The value to compare with this instance. |
Returns
Type | Description |
---|---|
Boolean |
true if the value of this instant is equal to the value of the other parameter;
otherwise, false.
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
Since 1.4.x
Availability net35-Client
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The System.Object to compare with this instance. |
Returns
Type | Description |
---|---|
Boolean |
true if the specified System.Object is equal to this instance;
otherwise, false .
|
Overrides
System.ValueType.Equals(System.Object)
GetHashCode()
Returns the hash code for this instance.
Since 1.4.x
Availability net35-Client
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer that is the hash code for this instance. |
Overrides
System.ValueType.GetHashCode()
ToString()
Returns a string representation of this interval. The format of this string is
not yet specified, and may change without notice.
Since 1.4.x
Availability net35-Client
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string representation of this interval. |
Overrides
System.ValueType.ToString()
Operators
Equality(Interval, Interval)
Implements the operator ==.
Since 1.4.x
Availability net35-Client
Declaration
public static bool operator ==(Interval left, Interval right)
Parameters
Type | Name | Description |
---|---|---|
Interval | left | The left. |
Interval | right | The right. |
Returns
Type | Description |
---|---|
Boolean | The result of the operator. |
Inequality(Interval, Interval)
Implements the operator !=.
Since 1.4.x
Availability net35-Client
Declaration
public static bool operator !=(Interval left, Interval right)
Parameters
Type | Name | Description |
---|---|---|
Interval | left | The left. |
Interval | right | The right. |
Returns
Type | Description |
---|---|
Boolean | The result of the operator. |
Implements
System.IEquatable<T>