C#比较两个List string是否相等

        /// <summary>
        /// 比较两个List string是否相等
        /// </summary>
        /// <param name="list1"></param>
        /// <param name="list2"></param>
        /// <returns></returns>
        private static bool SameListString(List<string> list1, List<string> list2)
        {
            if (null == list1 && null == list2)
                return true;
            if (null == list1 || null == list2)
                return false;
            if (list1.Count != list2.Count || !list1.All(list2.Contains))
                return false;
            list1.Sort();
            list2.Sort();
            int nCount = list1.Count;
            for(int n=0;n<nCount;n++)
            {
                if (0 != string.Compare(list1[n], list2[n], false))
                {
                    return false;
                }
            }
            return true;
        }

    原文作者:suixhcud
    原文地址: https://blog.csdn.net/a_dev/article/details/79000177
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞