Examining two string arrays for equivalence

前端 未结 5 1394
无人共我
无人共我 2021-01-21 21:38

Is there a better way to examine whether two string arrays have the same contents than this?

string[] first = new string[]{\"cat\",\"and\",\"mouse\"};
string[] s         


        
5条回答
  •  佛祖请我去吃肉
    2021-01-21 21:59

    You should consider using the intersect method. It will give you all the matching values and then you can just compare the count of the resulting array with one the arrays that were compared.

    http://msdn.microsoft.com/en-us/library/system.linq.enumerable.intersect.aspx

提交回复
热议问题