可能重复:
优化双 foreach 循环
我正在尝试将双 foreach 循环变成单个 foreach 循环
foreach (KeyValuePair<Int64, MyObject> kvp in originCounts)
{
    foreach (KeyValuePair<Int64, MyObject> testkvp in originCounts)
    {
    //Run Comparison on testkvp ad kvp to see if all elements of object are the same
    }
}
MyObject 是这样定义的
public class MyObject 
{
    public string FirstName{ get; set; }
    public string LastName{ get; set; }
    public int UserID { get; set; }
    public string Address { get; set; }
}
反正有没有使用一个循环来做到这一点?当它们都相同时,我将它们添加到 Int64 列表中。是同一个字典。