- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Date format validation using C# Regex
Use the DateTime.TryParseExact method in C# for Date Format validation.
They method converts the specified string representation of a date and time to its DateTime equivalent. It checks whether the entered date format is correct or not.
Example
using System; using System.Globalization; namespace Demo { class Program { static void Main(string[] args) { DateTime d; bool chValidity = DateTime.TryParseExact( "08/14/2018", "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out d); Console.WriteLine(chValidity); } } }
Output
True
Advertisements