使用 Id 属性对类列表进行排序?

Jam*_*123 0 c# vb.net asp.net

我有一个名为Questions. 此问题具有属性QuestionIDQuestionAnswer。我list of Questions有 QuestionID 像 2,3,4,15,12,24,22,,,, 等等

我需要根据 QuestionID 对这个问题列表对象进行排序并存储在另一个Questions对象中。

Ian*_*nry 5

有一个名为 LINQ 的框架专为此类任务而设计。例如,在 C# 中:

var sortedList = questionList.OrderBy(q => q.QuestionID).ToList();
Run Code Online (Sandbox Code Playgroud)