public SearchCriteria string searchstring int limit searchstring Trim

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public SearchCriteria(string searchstring, int limit)
{
searchstring.Trim();
string[] searchItems = searchstring.Split(' ');
_searchstring = string.Empty;
int count = 0;
//(" word1*" or "word2*" or "word3* ")
foreach (string searchItem in searchItems)
{
count = count + 1;
}
foreach (string searchItem in searchItems)
{
count = count - 1;
string item = searchItem.Trim(new char[] { ' ', '"', '*' });
if (!string.IsNullOrEmpty(item))
if (count == 0)
{
_searchstring += '"' + item + "*" + '"';
}
else
{
_searchstring += '"' + item + "*" + '"' + " or ";
}
}
searchstring = "(" + _searchstring + ")";
_limit = limit;
}