-3

我想搜索以另一个字符串开头的字符串。例子:

<br>
{<br>
Sujith,<br>
surjith,<br>
rejith,<br>
}</p><br>

如果搜索词是“su”,应该:

return<br>
{<br>
Sujith,<br>
surjith,<br>
}</p><br>
but not rejith
</p>
4

2 回答 2

0

You could use the Regex class and build up yourself a regular expression which does that.

于 2012-10-31T11:23:18.013 回答
0

You can use the StartsWith instance method on your string:

string searchString = "su";

List<string> result = nameList
                       .Where(x => x.StartsWith(searchString, true, System.Globalization.CultureInfo.CurrentCulture))
                       .ToList();
于 2012-10-31T11:23:18.793 回答