Array of dates returns object System datetime not the actual value of the array

Question is I have a function call "GetDatesBetween" what this does is looks at my two datepickers leave_s_dp and leave_e_dp and gets the dates between them. I then want to turn this array into a string for use in my full_range text box, But it always returns System.DateTime[]. Any help would be greatly appreciated.

public:
List<DateTime> ^GetDatesBetween(DateTime startDate, DateTime endDate)
{
    List<DateTime> ^allDates = gcnew List<DateTime>();

    for (DateTime date = startDate; date <= endDate; date = date.AddDays(1))
    {
            allDates->Add(date.Date);
    }



    return allDates;

}


private: 
System::Void submit_button_Click(System::Object^  sender, System::EventArgs^  e) {
             array<DateTime> ^dates = GetDatesBetween(leave_s_dp->Value.Date, leave_e_dp->Value.Date)->ToArray();

             //array<DateTime> ^dates = GetDatesBetween(leave_s_dp->Value, leave_e_dp->Value)->ToArray();


             String ^ days_between = dates->ToString();




             full_range_text->Text = days_between;


}
Jon Skeet
people
quotationmark

You're calling ToString() on an array. That doesn't do what you expect it to. It's not clear exactly what you do expect it to do, but it's almost certainly not what you want.

You quite possibly want to call string.Join, e.g.

dates_between = String::Join(", ", dates);

That will just use the default date format though - which may not be what you want either.

people

See more on this question at Stackoverflow