Converts the string to a DateTime, returning true if successful.
문법
DateTime.TryParse(s, out result)예제
아래 값을 입력하면 예제에 즉시 반영됩니다.
if→TryParse→out→dt→Console→WriteLine→ToString→bad→if (DateTime.TryParse("2024-06-15", out DateTime dt))
Console.WriteLine(dt.ToString("yyyy-MM-dd")); // "2024-06-15"
if (!DateTime.TryParse("invalid", out DateTime bad))
Console.WriteLine("Parse failed");