【发布时间】:2015-10-03 08:58:23
【问题描述】:
我想解析日期和时间。如果有格式异常,我想捕获并执行以下操作:
try
{
DateTime time = DateTime.Parse(Console.ReadLine());
}
catch (FormatException)
{
Console.WriteLine("Wrong date and time format!");
}
但是,当我开始使用值 'time' 时,C# 会说“名称 'time' 在当前上下文中不存在”。我的错在哪里?
【问题讨论】: