Kleine Ergänzung zu den vorherigen Antworten:
DateTime:
public static DateTime Parse(string s)
{
return DateTimeParse.Parse(s, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None);
}
public static bool TryParse(string s, out DateTime result)
{
return DateTimeParse.TryParse(s, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None, out result);
}
DateTimeParse:
internal static DateTime Parse(string s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
{
DateTimeResult result = new DateTimeResult();
result.Init();
if (!TryParse(s, dtfi, styles, ref result))
{
throw GetDateTimeParseException(ref result);
}
return result.parsedDate;
}
TryParse ist besser
Referenzen:
Reflector