NewtonianB
asked on
how to parse exact day"th"
How can I parse exact this string in c#?
It seems it works with DateTime.Parse() as long as the "th" is not there how can I fix this?
Friday 18th February 2011 8:11:04 AM
It seems it works with DateTime.Parse() as long as the "th" is not there how can I fix this?
Friday 18th February 2011 8:11:04 AM
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK, I agree - again good idea, I'd go with splitting and replacing dates[1].
However to use StringBuilder to re-assemble the string is an overkill, I think.
I'd write it as :
string cleaneddateStr = dates[0] + " " + dates[1] + " " + dates[2] + " " + dates[3] + " " + dates[4] + " " + dates[5]
Compiler is clever enough to create just a one string here so - no much overhead. With StringBuilder - quite a lot of overhead. I tested this couple of years ago.
Anyway, it works
However to use StringBuilder to re-assemble the string is an overkill, I think.
I'd write it as :
string cleaneddateStr = dates[0] + " " + dates[1] + " " + dates[2] + " " + dates[3] + " " + dates[4] + " " + dates[5]
Compiler is clever enough to create just a one string here so - no much overhead. With StringBuilder - quite a lot of overhead. I tested this couple of years ago.
Anyway, it works
ASKER
we forgot "nd" also
Here is a revised version.
Open in new window