samedi 31 octobre 2015

sort list using property variable

Suppose I have this list of process or any other object

List<Process> listProcess = new List<Process>();

I can sort it using this line listProcess.OrderBy(p => p.Id); But what if I have only string name of property obtained in runtime. I assume, I should use reflection to get the property object. Can I use orderby method or I should use Sort and then pass own comparer?





Aucun commentaire:

Enregistrer un commentaire