Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse a list c#

Tags:

c#

asp.net

I have inserted the EventData EntityList into a normal List and now I want to reverse it. But it gives the error "Cannot implicitly convert type 'void' to 'object'"

List<Entities.Notification> ProgramList = EventData.ToList();
ListViewEvents.DataSource = ProgramList.Reverse();
ListViewEvents.DataBind();

How do I reverse this list? Is it possible to directly reverse the EntityList as well?

like image 634
user1733271 Avatar asked Nov 27 '22 09:11

user1733271


1 Answers

Reverse does the reversal in place and does not return anything. Instead do:

List<Entities.Notification> ProgramList = EventData.ToList();
ProgramList.Reverse();
ListViewEvents.DataSource = ProgramList;
ListViewEvents.DataBind();
like image 177
Brian Maupin Avatar answered Dec 05 '22 00:12

Brian Maupin