I have a method that currently takes a DateTime startDate
and DateTime endDate
. It would be really great if there would be a datatype that consists of two DateTime
so that my method only has to take one value instead of two.
I am specifically looking for a single type, but if it's not possible I guess I have to create my own DatePeriod
class.
Solution
After looking into this for some more time I finally came to realize that there is no perfect answer to my question. So now I created my own class holding the two values, a Tuple would work just as fine though.
Here's the code (almost exact same as in StepUp's Answer, but I use a struct):
public struct DatePeriod
{
public DateTime Start { get; set; }
public DateTime End { get; set; }
public DatePeriod(DateTime startDate, DateTime endDate)
{
Start = startDate;
End = endDate;
}
}