I am in a position where I need to define many points in time at as
precise a way as possible in .NET. I'm already looking into
millisecond precision, and I know this is a tired subject for you all,
so I'll avoid it.
What I do want to ask you about is how to define my timestamp as an
attribute I can refer to as easily as, say, "String" is. For example,
I want to define many class attributes as Timestamp (or any name I
make up), and that Timestamps is simply a string of 20 characters.
[For this question, I'll just say that the format is:
YYYYMMDDhhmmssiiiuuu, and yes, I know that .NET will not allow
microsecond precision for time. These values will be exchanged with
Linux systems that do.]
Right now, Withing a class I have a choice of making the value a
String, as in:
Dim _Created As String
Public Property Created() As String
Get
If True Then
Return _Created
Else
Throw New ArgumentOutOfRangeException
End If
End Get
Set(ByVal Created As String)
If True Then
_Created = Created
Else
Throw New ArgumentOutOfRangeException
End If
End Set
End Property
...which requires me to check for valid format each and every time the
"Set" is called, or some other way in which I am declaring instances
of a class that will basically do the same thing.
What would be faster/easier/simpler would be defining a Timestamp
class/structure that would:
1. Allow definition via a static call/constructor
2. Would not allow a malformed value (not exactly 20 chars, a letter
or symbol in there somewhere, etc.)
Is it possible to do this with a Class? Do I need to inherit
System.Object?
Any hints appreciated! TIA!
pat
:)