I've written the following Extension Method
<Extension()>
Public Function ToUtcIso8601(ByVal dt As Date) As String
Return String.Format("{0:s}Z", dt)
End Function
But I also need a Nullable version of the same method... how exactly do I do this?
This is what I was thinking, but I'm not sure if this is the right way
<Extension()>
Public Function ToUtcIso8601(ByVal dt As Date?) As String
Return If(dt, Nothing).ToUtcIso8601()
End Function
or another option
<Extension()>
Public Function ToUtcIso8601(ByVal dt As Date?) As String
Return If(Not dt Is Nothing, ToUtcIso8601(dt), Nothing)
End Function
I'm just not sure the "right" way to do this.
Edited
This actually works, But...
Public Function ToUtcIso8601(ByVal dt As Date?) As String
Return If(Not dt Is Nothing, ToUtcIso8601(dt.Value), Nothing)
End Function
Is this the right way to do this?