I think Viv mentioned TryParseExact
using System.Globalization;
DateTime dt;
if (DateTime.TryParseExact("20100510", "yyyyMMdd", null, DateTimeStyles.None, out dt))
{
Console.WriteLine(" {0}", dt);
}
else
{
Console.WriteLine(" no match");
}
Console.ReadLine();
>Many thanks for all replies.
>Still am not sure of the answer though, without wading through tons and tons of stuff.
>
>Is there any .net equivalnet ( ={^2011-05-10} ) that will A-L-W-A-Y-S return correct date, irrespective of the local
>Seems to be a divergence of opinion in the answers , or am I picking them up wrong ?
>
>Regards,
>Gerard
>
>
>>Look at this article to see if it helps
>>
>>
http://msdn.microsoft.com/en-us/library/ms973825.aspx>>
>>
>>>Hi.
>>>
>>>VFP
>>>x={^2011-05-10} ALWAYS returns 10th May 2011 no matter what the culture is
>>>
>>>C#
>>>dateValue = DateTime.Parse("2011-05-10");
>>> Does this ALWAYS return 10th May, 2011 or are there instances when I could get 5th October 2011 ?
>>> If so, can it be made unambiguous , similar to the ^ in VFP
>>>Tia
>>>Gerard
Gregory