Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using TestInput;
- /*
- from Lesson 6 of C# console programming tutorial series at following URL:
- http://williammillerservices.com/windows-c-console-programming/
- demonstrates functionality of helper method IsDate() that we added
- to tester.cs
- GitHub gist -> https://gist.github.com/kyrathasoft/a2b9ed62224e7513161e43c96c5611b1
- Pastebin.com -> https://pastebin.com/Xfu5CuEE
- */
- namespace TestParsingOfStringToDateAndToInteger
- {
- class MyTesterClass
- {
- static void Main(string[] args)
- {
- //two test strings
- string sTest1 = "the ninth of July, 2018";
- string sTest2 = "7/9/2018";
- Console.WriteLine(); //print blank line...
- CanParseToDate(sTest1);
- CanParseToDate(sTest2);
- }
- static void CanParseToDate(string p)
- {
- if (Tester.IsDate(p))
- {
- /* We use a placeholder for variable 'p' value and we end
- the argument passed to WriteLine() with an extra line: \n
- to aid readability during program execution */
- Console.WriteLine("\"{0}\" can be parsed to a DateTime.\n", p);
- }
- else
- {
- Console.WriteLine("\"{0}\" cannot be parsed to a DateTime.\n", p);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement