#Region "Operators for System.DateTime" ''' <summary> ''' Converts a System.DateTime structure to a DateTimeNull object. ''' </summary> ''' <param name="value">A DateTime structure. </param> ''' <returns>A DateTimeNull object whose Value is equal to the combined Date and TimeOfDay properties of the supplied System.DateTime structure.</returns> Public Shared Widening Operator CType(ByVal value As System.DateTime) As DateTimeNull Return New DateTimeNull(value) End Operator ''' <summary> ''' Converts a DateTimeNull object to a System.DateTime structure. ''' </summary> ''' <param name="value">a DateTimeNull</param> ''' <returns>A System.DateTime structure whose Value is equal to the combined Date and TimeOfDay properties of the supplied DateTimeNull object.</returns> Public Shared Widening Operator CType(ByVal value As DateTimeNull) As System.DateTime If value.HasValue Then Return value.InternalDate Else Throw New InvalidCastException("Cannot convert Null DateTimeNull to System.DatetTime.") End If End Operator #End Region
Dim nullableDate As DateTimeNull = Nothing Dim systemDate As System.DateTime nullableDate = systemDate systemDate = nullableDate
If nullableDate = systemDate Then End If If systemDate = nullableDate Then End If
''' <summary> ''' Determines whether one specified DateTimeNull is equal to another specified DateTime. ''' </summary> ''' <param name="d1">A DateTimeNull.</param> ''' <param name="d2">A System.DateTime.</param> ''' <returns><c>true</c> if d1 is not null and d1 is equal to d2; otherwise, false.</returns> Public Shared Operator =(ByVal d1 As DateTimeNull, ByVal d2 As System.DateTime) As Boolean If d1.HasValue Then Return (d1.InternalDate = d2) Else Return False End If End Operator ''' <summary> ''' Determines whether one specified DateTimeNull is not equal to another specified DateTime. ''' </summary> ''' <param name="d1">A DateTimeNull.</param> ''' <param name="d2">A System.DateTime.</param> ''' <returns><c>true</c> if d1 is not null and d1 is not equal to d2; otherwise, false.</returns> Public Shared Operator <>(ByVal d1 As DateTimeNull, ByVal d2 As System.DateTime) As Boolean If d1.HasValue Then Return Not (d1.InternalDate = d2) Else Return False End If End Operator
''' <summary> ''' Determines whether one specified System.DateTime is equal to another specified DateTimeNull. ''' </summary> ''' <param name="d1">A System.DateTime.</param> ''' <param name="d2">A DateTimeNull.</param> ''' <returns><c>true</c> if d1 is not null and d1 is equal to d2; otherwise, false.</returns> Public Shared Operator =(ByVal d1 As System.DateTime, ByVal d2 As DateTimeNull) As Boolean If d2.HasValue Then Return (d1 = d2.InternalDate) Else Return False End If End Operator ''' <summary> ''' Determines whether one specified System.DateTime is not equal to another specified DateTimeNull. ''' </summary> ''' <param name="d1">A System.DateTime.</param> ''' <param name="d2">A DateTimeNull.</param> ''' <returns><c>true</c> if d1 is not null and d1 is not equal to d2; otherwise, false.</returns> Public Shared Operator <>(ByVal d1 As System.DateTime, ByVal d2 As .DateTimeNull) As Boolean If d2.HasValue Then Return Not (d1 = d2.InternalDate) Else Return False End If End Operator
''' <summary> ''' Determines whether one specified DateTimeNull is less than or equal to another specified System.DateTime. ''' </summary> ''' <param name="d1">A DateTimeNull.</param> ''' <param name="d2">A System.DateTime.</param> ''' <returns><c>true</c> if d1 is not null and d1 is less than or equal to d2; otherwise, false.</returns> Public Shared Operator <=(ByVal d1 As DateTimeNull, ByVal d2 As System.DateTime) As Boolean If d1.HasValue Then Return (d1.InternalDate <= d2) Else Return False End If End Operator ''' <summary> ''' Determines whether one specified DateTimeNull is greater than or equal to another specified System.DateTime. ''' </summary> ''' <param name="d1">A DateTimeNull.</param> ''' <param name="d2">A System.DateTime.</param> ''' <returns><c>true</c> if d1 is not null and d1 is greater than or equal to d2; otherwise, false.</returns> Public Shared Operator >=(ByVal d1 As DateTimeNull, ByVal d2 As System.DateTime) As Boolean If d1.HasValue Then Return (d1.InternalDate >= d2) Else Return False End If End Operator
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.