C# 合并列表对象

C# 合并列表对象,c#,asp.net,collections,C#,Asp.net,Collections,我有一个asp.net应用程序,其中有4个列表集合对象 List<string> sTransID = new List<string>(); List<string> sOriginID = new List<string>(); List<string> sDestID = new List<string>(); List<string> sCourierID = new List<string>

我有一个asp.net应用程序,其中有4个列表集合对象

List<string> sTransID = new List<string>();
List<string> sOriginID = new List<string>();
List<string> sDestID = new List<string>();
List<string> sCourierID = new List<string>();
这些对象填充在类内应用程序的不同部分,或aspx代码隐藏等。当列表元素大小增加时,页面性能会显著降低

在读取这些对象的值时,什么是循环这些对象的最快方式,以避免必须循环4个对象?我是否可以将这些对象合并到父列表对象中并在父列表对象中循环

更新: 我所说的合并是指:

var Parent = List<sTransID>, List<sOriginID>, List<sDestID>, List<sCourierID>  
var GetLocation = Parent[0];  // will return TransID[0], Origin[0], DestID[0], CourierID[0]

我有一个合并字典的扩展方法。如果您为列表修改它,可能会有所帮助

public static class DictionaryExtensions
{
    public static T MergeLeft<T, K, V>(this T me, params IDictionary<K, V>[] others)
        where T : IDictionary<K, V>, new()
    {
        var newMap = new T();

        foreach (var p in (new List<IDictionary<K, V>> { me }).Concat(others).SelectMany(src => src))
        {
            newMap[p.Key] = p.Value;
        }

        return newMap;
    }

}
用法如下:

var mergedDictionary = new Dictionary<string, string>().MergeLeft(dic1, dic2, dic3);

一种方法是在循环之前将列表连在一起:

var itemsToLoop = sTransID.Concat(sOriginID).Concat(sDestID).Concat(sCourierID);

速度快吗?可能只是一点点。如果搜索是您的瓶颈,那么您应该使用更好的数据结构better=更高效的搜索。Hastable或有序列表(如果适用)列表之间的关系是什么?sTransID.UnionsOriginID.UnionsDestID.unionscourieriid?为什么不能使用linq?@Csharp您应该将其添加到问题中。