1) Trim leading/trailing '+':
myLine = myLine.Trim(new char[] {'+'})
;
2) Split each line by '-': use:
char[] terms = myLine.Split(new char[] {'-'})
;
3) The split will give you array of char with 4 terms; parse first one (terms[0]) to
System.DateTime
using
System.DateTime.Parse(string, IFormatProvider, DateTimeStyles)
or
System.DateTime.ParseExact(string, string, IFormatProvider)
; make sure to use appropriate
CultureInfo
as an instance of
IFormatProvider
to match culture-specific date/time format (from your example, one cannot understand which number is month and which is day, but you should know this from the culture); in second case, use appropriate explicit format string (see references below).
4) Parse other terms using your type; as '-' is a delimiter and not sign, your type is unsigned; so it could be
byte, ushort, uint, ulong
; in all cases, use
Parse
or
TryParse
, for example
uint.Parse(term[index])
, where your index is 1 to 3.
See:
http://msdn.microsoft.com/en-us/library/system.string.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[
^],
http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx[
^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[
^].
—SA