Groups | Blog | Home
all groups > dotnet framework > april 2007 >

dotnet framework : How to determine a string is in valid dateTime format



Andrew
4/18/2007 1:20:00 PM
Hello, friends,

What is the best way to determine a string is in valid dateTime format?

Andrew
4/18/2007 2:52:04 PM
Thank you guys. I used DateTime.TryParse().

Also, another question: How to quickly convert a collection into an array?

Scott M.
4/18/2007 4:34:04 PM
Try casting it to a DateTime inside of a try...catch? Use RegEx?



[quoted text, click to view]

Aleksander Polak
4/19/2007 12:21:06 AM
[quoted text, click to view]

It depends on the collection. ArrayList and List<T> have a parameterless
ToArray method, which creates an array containing elements from the
collection. In addition, ICollection and ICollection<T> exposes a CopyTo
method, which can be used in the following manner:

Widget[] arr = new Widget[coll.Count];
coll.CopyTo(arr, 0);

--
Aleksander Polak
Alex Meleta
4/19/2007 12:38:45 AM
DateTime.TryParse() and such.

WBR, Alex Meleta
Blog: http://devkids.blogspot.com

-----Original Message-----
From: Andrew [mailto:Andrew@discussions.microsoft.com]
Posted At: Donnerstag, 19. April 2007 00:20
Posted To: microsoft.public.dotnet.framework
Conversation: How to determine a string is in valid dateTime format
Subject: How to determine a string is in valid dateTime format

Hello, friends,

What is the best way to determine a string is in valid dateTime format?

Thanks a lot.
AddThis Social Bookmark Button