小编HGB*_*BRD的帖子

C#字符串匹配(结果)来自.txt文件

TEXT.txt:

who     
when   
what   
how
Run Code Online (Sandbox Code Playgroud)

Example.cs:

String example = "what is the time" ;

foreach (string line in File.ReadLines(@"C:\TEXT.txt"))
{
    if (example.Contains(line))
    {
        Messagebox.Show("True, the match is 'what'");
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经创建了一个文本文件,TEXT.txt以及一段代码,用于检查文本文件中的任何行是否与示例字符串中的某些内容匹配.我如何看到实际匹配是什么?在这种情况下,它会what.

c# foreach file contains match

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

标签 统计

c# ×1

contains ×1

file ×1

foreach ×1

match ×1