To check if string is date in C# and VB.NET you can use the following snippet.

Sample C#

public bool IsDate(string input)
{
	DateTime result;
	return DateTime.TryParse(input, out result);
}

Sample VB.NET

Public Function IsDate(input As String) As Boolean
	Dim result As DateTime
	Return DateTime.TryParse(input, result)
End Function

One thought on “How to check if string is date in C# and VB.NET”

Leave a Reply