Hi chetan,
Firtly - Both the first solutions are of great for your simple purpose.
I want to suggest however, that you learn a bit about Regular Expressions, those will prove extremely useful for search purposes, and are basically a must tool for developers.
See a little example:
string TheText = "Here comes your bulk of text with the pattern to find.";
string WhatToFind_Pattern = "the pattern to find";
if (System.Text.RegularExpressions.Regex.IsMatch(TheText, WhatToFind_Pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
}
Useful links in case you want to get into Regex:
-
Learn Regular Expressions (RegEx) with Ease[
^]
-
Validation with Regular Expressions Made Simple[
^]
-
Regex Quick Reference[
^]
Cheers,
Edo