【发布时间】:2013-01-17 15:17:40
【问题描述】:
我有两个相同类型对象的列表。
一个列表来自系统管理员,另一个来自查看页面的用户。
这些列表必须在某个时候合并才能查看,并且列表排序所依据的值 position 可能会有冲突的值。
有没有办法合并两个列表,当找到相同的位置值时,将较低(因此更好)的位置分配给管理列表?
示例
class info
{
int position;
string title;
}
List<info> adminInfo = new List<info>
{
new info() {position = 0, title = "adminOne"}
new info() {position = 4, title = "adminThree"}
new info() {position = 3, title = "adminTwo"}
}
List<info> userInfo = new List<info>
{
new info() {position = 0, title = "userOne"}
new info() {position = 3, title = "userTwo"}
}
List<info> PreferentiallySortedList(List<info> adminList, List<info> userList)
{
//Some kind of magic here
}
//Looping through PreferentiallySortedList and displaying
//the title of each item should return the following:
"adminOne"
"userOne"
"adminTwo"
"userTwo"
"adminThree"
【问题讨论】: