Reputation: 33
I want to create a class that simulates times. Here is what I have so far.
namespace TimeSimulationConsole
{
class Program
{
static void Main(string[] args)
{
Time startTime = new Time();
startTime.Day = 1;
startTime.Month = 1;
startTime.Year = 2000;
DateTime gameDate = DateTime.Parse(startTime.Day, startTime.Month, startTime.Year);
Console.WriteLine(gameDate);
Console.ReadLine();
}
}
class Time
{
public int Day { get; set; }
public int Month { get; set; }
public int Year { get; set; }
}
}
I basically want to define a start time, that I can later modify, or add days to it. But for now I just want to convert it to DateTime and show it via console.
The code I wrote doesn't work, it seems I can't parse startTime.
Upvotes: 1
Views: 39
Reputation: 26
class Program
{
static void Main(string[] args)
{
Time startTime = new Time();
startTime.Day = 1;
startTime.Month = 1;
startTime.Year = 2000;
DateTime gameDate = new DateTime(startTime.Year, startTime.Month, startTime.Day);
Console.WriteLine(gameDate);
Console.ReadLine();
}
}
class Time
{
public int Day { get; set; }
public int Month { get; set; }
public int Year { get; set; }
}
Upvotes: 1