Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 DateTime 中转换以下格式。我想将其转换为日期时间
“08-22T03:32”
由于您的日期字符串中没有年份,因此默认为当前年份,如下所示:
DateTime dt = DateTime.ParseExact(dateString, "MM-ddTHH:mm", CultureInfo.InvariantCulture);
如果字符串格式正确,则DateTime.Parse()就是您要查找的内容。但我认为该字符串的“日期”部分不完整,无法正常工作。