In your code, you are not reading the file, and, as Dave K. points out, you are not specifying exactly what you need to return if there is a match. What if there are multiple matches ?
However, there are ways to "package" two (or more) types of values/objects and return them from a Method.
For example, you could use a KeyValuePair to return two items of different Types:
private KeyValuePair<bool, string> parseResult(string searchString, string contentString)
{
return (contentString.Contains(searchString))
? new KeyValuePair<bool, string> (true, contentString)
: new KeyValuePair<bool, string>(false, String.Empty);
}
Which you might use like this:
var searchResult = parseResult("yes", "no and yes.");
if (searchResult.Key)
{
}
else
{
}
You could also use the Tuple Class to return two (or more) items of different Types:
private Tuple<bool, string> parseResult2(string searchString, string contentString)
{
return (contentString.Contains(searchString))
? new Tuple<bool, string>(true, contentString)
: new Tuple<bool, string>(false, String.Empty);
}
And, use it like this:
var searchResult2 = parseResult2("yes", "no and yes.");
if (searchResult2.Item1)
{
}
else
{
}
There's nothing unusual about packaging multiple Types into a return of a method: you'll not the TryParse methods kind-of do this by demanding you pass in a variable using 'ref which is then modified to hold the content if there's a match.
And, of course, you could define a Class, or Struct, with as many Fields/Types as you wish, and have your analytic Method return an instance of the Class, or Struct. In this response I decided to use KeyValuePair, and Tuple, examples for ... variety.