Comparing two string arrays in C#

前端 未结 5 538
暖寄归人
暖寄归人 2021-01-07 16:18

Say we have 5 string arrays as such:

string[] a = {\"The\",\"Big\", \"Ant\"};
string[] b = {\"Big\",\"Ant\",\"Ran\"};
string[] c = {\"The\",\"Big\",\"Ant\"};         


        
5条回答
  •  一生所求
    2021-01-07 16:34

            if (a.Length == d.Length)
            {
                var result = a.Except(d).ToArray();
                if (result.Count() == 0)
                {
                    Console.WriteLine("OK");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }
    

提交回复
热议问题