DateTime seems like a NightMare

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Hi All

I am really having problems with the DateTime class.
Please can someone tell me how to pass a simple string
like "26/05/2003" or "2003/05/26" etc into a DateTime
class. When I read the help, I am seeing things Like
Cultureinfo classes, IFormatProvider, Calendar Classes, I
don't know whats what, please can someone explain all
this for me, or point me in the right direction. As
you've probably guessed, I am new to C#, so I'm finding
it a bit difficult to grasp some of these concepts. I
don't see why I cant just pass the string and tell the
class I want it formatted like "dd/mm/yyy"

Any help is much appreciated
TIA
Kevin
 
Kevin said:
I am really having problems with the DateTime class.
Please can someone tell me how to pass a simple string
like "26/05/2003" or "2003/05/26" etc into a DateTime
class.

Use DateTime.ParseExact with the IFormatProvider being
CultureInfo.InvariantCulture or CultureInfo.CurrentCulture
I don't see why I cant just pass the string and tell the
class I want it formatted like "dd/mm/yyy"

And you can - but the framework gives good infrastructure to allow for
culture-sensitive settings.
 
Back
Top