using System;
using System.Globalization;
public class DateTimeParser
{
public static void Main()
{
DateTime dateValue;
string dateString = "2/16/2008";
try {
dateValue = DateTime.Parse(dateString);
Console.WriteLine("'{0}' converted to {1}.", dateString, dateValue);
}
catch (FormatException) {
Console.WriteLine("Unable to convert '{0}'.", dateString);
}
}
}
|