我有2泛型列表名单,其中,TYPE1> L1
,名单,其中,2型> L2
在C#3.5
I have 2 generic Lists List<type1> L1
, List<type2> L2
in C# 3.5
问题: TYPE1有一个名为键1和type2的属性有一个属性叫做KEY2 如何合并的键1 =键2 L1和L2。 这两个列表都是无序,但我欢迎就如何名单根据属性进行排序的任何想法。
Problem: type1 has an attribute called "key1" and type2 has an attribute called "key2" How to merge L1 and L2 on key1 = key2. Both lists are unsorted but I'm welcome to any ideas on how to sort the lists based on the attribute.
我希望能够合并在一个关键的两个列表。我知道这不是一本字典,它会一直很好,如果它是,但有一个非常特殊的原因,他们的名单,我不会得到到,因为这是不相关的。
I'd like to be able to merge the two lists on a key. I know it's not a dictionary and it would've been nice if it was but there is a very specific reason why they are lists which I will not get in to because that is irrelevant.
我相信你要求的加入操作。这是简单的,但你将需要更加具体,以获得更好的答案。
I believe you're asking for the Join operation. It's straightforward, but you are going to need to be more specific to get better answers.
var joined = from item1 in L1
join item2 in L2
on item1.Key1 equals item2.Key2
orderby item1.Key1
select new
{
// your selected objects/properties here
};
上一篇:如何检查DST和夏令时是在Android应用程序或关闭夏令时、是在、应用程序、DST
下一篇:Silverlight的,我可以访问WebBrowser控件中的DOM元素?控件、元素、Silverlight、WebBrowser