I'm trying to create a program that outputs an itinerary, but I'm having issues with finding a way around my two DateTime
objects pointing towards the same object. A specific DateTime
is passed as an argument into the method and I use two other DateTime
object within the method (which both currently point to the argument)
None of my normal fixes like memberwiseClone()
work for DateTime
, so I'm at a bit of a loss.
{
DateTime1 = x;
for (int i = 0; i < someArray.Length; i++)
{
DateTime2 = DateTime1;
double minutes = someValue / someOtherValue;
DateTime2.AddMinutes(minutes);
WriteLine("{0:hh//:mm} ---> {1:hh//:mm}, item #{2}", DateTime1, DateTime2, i);
DateTime1 = DateTime2;
}
}
I would ideally like it to print out something along the lines of:
"21:00 ---> 21:30, item #1"
"21:30 ---> 22:00, item #2"
However, at the moment I'm just getting all values at the initial value of the DateTime
argument.