I am using them both and they seem the same.
Is one better to use than another?
Thanks,
Tom
Convert.ToDateTime uses DateTime.Parse internally, with the current
culture - unless you pass it null, in which case it returns
DateTime.MinValue.
--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
I bet one use the other, yep, according to MSDN Convert.ToDatetime use
DateTime.Parse. At least the overload method that receive a string.
and it seems that is the only one being used , all the other overloads of
Convert.ToDateTime says it throw an exception
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"tshad" <tschei...@ftsolutions.com> wrote in message
news:ufN$u4KZGH...@TK2MSFTNGP05.phx.gbl...
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
I can use either - just flip a coin :)
Thanks,
Tom
"Fabio" <znt....@virgilio.it> wrote in message
news:elm$yYLZGH...@TK2MSFTNGP04.phx.gbl...