小编Dom*_*Dom的帖子

找不到独特的单词

谁能告诉我我的代码有什么问题?基本上,我只需要添加从唯一码字words1uniques列表中,以后我比较这两个words1words2.在if声明中,如果我删除!然后它找到匹配的单词(与我需要的相反)

    List<string> Unique(string lines1 ,string lines2,  char[] separators)
    {
        string[] words1 = lines1.Split(separators, StringSplitOptions.RemoveEmptyEntries);
        string[] words2 = lines2.Split(separators, StringSplitOptions.RemoveEmptyEntries);
        List<string> uniques = new List<string>();

        for (int i = 0; i < words1.Length; i++)
        {
            bool match;
            for (int x = 0; x < words2.Length; x++)
            {
                if (!words1[i].Equals(words2[x]))
                {
                    match = true;
                    uniques.Add(words1[i]);
                    break;
                }
                else
                {
                    match = false;
                }
            }
        }

        return uniques;
    }
Run Code Online (Sandbox Code Playgroud)

c# string-matching

1
推荐指数
1
解决办法
77
查看次数

标签 统计

c# ×1

string-matching ×1