Reputation: 89
TEXT.txt:
who
when
what
how
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'");
}
}
I've made a text file, TEXT.txt
, and a piece of code that checks if any of the lines in the text file match something in the example string. How do I see what the actual match is? In this case it would be what
.
Upvotes: 0
Views: 138
Reputation: 10460
You can do that:
Messagebox.Show("True, the match is '" + line + "'");
Upvotes: 2
Reputation: 36393
Is the "actual match" not just the variable line? Hence:
Messagebox.Show(string.Format("True, the match is '{0}'", line));
Upvotes: 5