Another gem in .NET 2.0. Parsing a string to get a datetime used to be pretty complex. But now with the DateTime.ParseExact(...) method you can specify the exact format of your string.
string s = "20071231T214559";DateTime d = DateTime.ParseExact( s, "yyyyMMddTHHmmss", null );this.textBox2.Text = d.ToString(); // this will print: 31-12-2007 21:45:59
Steve Tibbet has a post describing all the options for specifying the format.
dasBlog theme by Mads Kristensen
Concepts LINQ Entity Framework WCF WPF RESTful Web Unit Testing .NET Workflow More >>
Tools Visual Studio Windows IIS Silverlight More >>
Type Screencast Tools Video Newsletter Sample Article Books Magazine How To Demo Course Products More >>