Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C# - Date Validation
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Globalization; namespace Rextester { public class Program { public static void Main(string[] args) { Console.WriteLine("START"); CultureInfo enUS = new CultureInfo("en-US"); string dateString; DateTime dateValue; // Parse date with no style flags. dateString = " 2/ 29 /2008"; DateTime dateTest = new DateTime(2009,5,31); if (DateTime.TryParseExact(dateString, "M/d/yyyy", enUS, //CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces,// & DateTimeStyles.AssumeLocal, out dateValue)) Console.WriteLine("Converted '{0}' to {1} ({2}).", dateString, dateValue, dateValue.Kind); else Console.WriteLine("'{0}' is not in an acceptable format.", dateString); //if (dateString == dateValue.ToString("M/d/yyyy")) //if (dateString == dateValue.ToShortDateString()) if (dateTest == dateValue) Console.WriteLine("true"); else Console.WriteLine("false"); Console.WriteLine("END"); } } }
run
|
edit
|
history
|
help
0
DateTime
rathit
RHGFEC WQWQW
Math 10.94 test
Classes
TCP
Evo Ivana da budes fancy :D
123
Intuit // C# // listing_4.9 (do_while // kupi_slonika
Game Dev Challenge #1