A
A
Alexey Smirnov2017-10-14 01:48:11
.NET
Alexey Smirnov, 2017-10-14 01:48:11

How to list days in C#?

Hello.
There is a starting date: day, month, year.
There is an end date: day, month, year.
I need to sequentially list all days from "start date" to "end date".
How to implement this in C#?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2017-10-14
@ERAFY

var beginDate = DateTime.Now;
var futureDate = beginDate.AddDays(365);

for (var date = beginDate; date < futureDate; date = date.AddDays(1))
{
    Console.WriteLine(date.ToString());
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question