Guest User

Untitled

a guest
Jun 11th, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2.  
  3. namespace LawfulAge
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string inputFormat = "d-M-yyyy";
  10.             string outputFormat = "dd-MM-yyyy";
  11.  
  12.             string inputString = Console.ReadLine();
  13.  
  14.             DateTime dateOfBirth = DateTime.ParseExact(inputString, inputFormat, System.Globalization.CultureInfo.InvariantCulture);
  15.             int yearsToAdd = 18;
  16.             DateTime dateWithAddedYears = dateOfBirth.AddYears(yearsToAdd);
  17.             Console.WriteLine(dateWithAddedYears.ToString(outputFormat));
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment