因此,以下代码提供了Name' CultureInfo'在当前的上下文中不存在,我尝试了其他IFormatProviders,但他们没有在Visual Studio中注册。我做错了什么?
static void runTimeConverter()
{
double arrivalTime;
arrivalTime = getArrivalTime();
string time = DateTime.ParseExact(arrivalTime, "HHmm", CultureInfo.CurrentCulture)
.ToString("hh:mm tt");
Console.WriteLine("Equals " + time);
}
static double getArrivalTime()
{
Console.WriteLine
("Enter time in 24 hour format to convert to 12hour");
string timeSelected = Console.ReadLine();
int timeInput = int.Parse(timeSelected);
return timeInput;
}
答案 0 :(得分:1)
确保将其添加到文件顶部:
using System.Globalization;