"tshad" <ts**********@ftsolutions.com> ha scritto nel messaggio
news:uf**************@TK2MSFTNGP05.phx.gbl...
Is there any difference between convert.ToDateTime and
System.DateTime.Parse?
I am using them both and they seem the same.
Is one better to use than another?
This is Convert.ToDateTime(string)
public static DateTime ToDateTime(string value)
{
if (value == null)
{
return new DateTime((long) 0);
}
return DateTime.Parse(value, CultureInfo.CurrentCulture);
}
And this is DateTime.Parse(string)
public static DateTime Parse(string s)
{
return DateTimeParse.Parse(s, DateTimeFormatInfo.CurrentInfo,
DateTimeStyles.None);
}
That calls
internal static DateTime Parse(string s, DateTimeFormatInfo dtfi,
DateTimeStyles styles)
{
DateTimeResult result1 = new DateTimeResult();
result1.Init();
if (!DateTimeParse.TryParse(s, dtfi, styles, ref result1))
{
throw DateTimeParse.GetDateTimeParseException(ref result1);
}
return result1.parsedDate;
}
For details give it a look with Reflector.
--
Free .Net Reporting Tool -
http://www.neodatatype.net