I am trying to parse a string of events into a list EventsList, then populate the fields in my listview (title, location, time, and date) with the correct strings from EventList. The problem I have run into now is that the method used to populate EventsList is returning something that is no where to be found in my string. The string displayed from EventsList is:
System.Collections.GenericList'1[System.String]
If anyone could help me figure out why it is returning that it would be much appreciated - or if there is a better strategy to do this please enlighten me.
List<string> EventsList = new List<string>();
EventsList = EventDetails(EventsList);
List<string> EventDetails(List<string> arEvents)
{
int indexNum = 67;
string events = GetEvents();
//while (indexNum <= 78)
//{
int index1 = (events.IndexOf(indexNum.ToString())) + 2;
int commaIndex = events.IndexOf(",");
if ((commaIndex - index1) <= 0)
{
string Title = events.Substring(index1, 10);
indexNum++;
}
else
indexNum++;
// }
Title = events.Substring(index1, 10);
arEvents.Add(Title);
return arEvents;
}
MainListView.ItemsSource = new List<APBEvent>
{
new APBEvent()
{
EventTitle = GetEvents(),
EventLocation = "line break",
EventTime = EventsList.ToString(),
EventDate = "5/11/18",
},
};
EventsList.ToString()
EventList is list<string>
and you can not convert list
to string
.
If you want to convert list<string>
contents to string
then you can join the contents by using string.join
string.join(",",EventList);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.