Konversi char ke c
using System;
namespace Dates
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter date");
string dateInput = Console.ReadLine();
Console.WriteLine("Enter time");
string timeInput = Console.ReadLine();
Console.WriteLine("Enter number of hours to add");
string hoursInput = Console.ReadLine();
int hours = int.Parse(hoursInput);
string[] timeParts = timeInput.Split(":");
string[] dateParts = dateInput.Split("-");
DateTime date = new DateTime(
int.Parse(dateParts[0]),
int.Parse(dateParts[1]),
int.Parse(dateParts[2]),
int.Parse(timeParts[0]),
int.Parse(timeParts[1]),
0
);
date = date.AddHours(hours);
Console.WriteLine(date.ToString("yyyy-MM-dd HH:mm"));
}
}
}
Tough Tortoise