• Source
    1. using System;
    2.  
    3. public class Test
    4. {
    5. public static void Main()
    6. {
    7. // Exam 1:
    8. string s = "1990-06-26";
    9. DateTime date;
    10. bool d = DateTime.TryParse(s, out date);
    11.  
    12. // If TRUE
    13. if(d)
    14. Console.WriteLine(date);
    15.  
    16.  
    17. // Exam 2:
    18. string s2 = "2014";
    19. int integer;
    20. bool i = Int32.TryParse(s2, out integer);
    21. if(i)
    22. Console.WriteLine(integer);
    23.  
    24. Console.ReadKey();
    25. }
    26. }