Parse a string to DateTime

To illustrate, suppose we generate a culture-insensitive DateTime string s as follows:


using System;
using System.Text;
using System.Globalization;
class Sample
{
    public static void Main()
    {
        string s = DateTime.Now.ToString("o");
        Console.WriteLine(s);
        DateTime dt1 = DateTime.ParseExact(s, "o", null);
        Console.WriteLine(dt1);
    }
}

The output:


2010-12-15T13:09:49.7744687-08:00
12/15/2010 1:09:49 PM
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.