Make this C# looking for Exact Match?

convict29

Пользователь
Регистрация
10.07.2014
Сообщения
114
Благодарностей
3
Баллы
18
Hi, i have this code
Код:
// take text for search from a variable
var textContains = project.Variables["tableSearchTextContains"].Value;
// get table for search
var sourceTable = project.Tables["SourceTable"];
// search in each row
lock(SyncObjects.TableSyncer)
{
    for(int i=0; i < sourceTable.RowCount; i++)
    {
        // read a row (array of cells)
        var cells = sourceTable.GetRow(i).ToArray();
        // loop through all cells
        for (int j=0; j < cells.Length; j++)
        {
            // check if cell contains specified text, if there are matches return "yes"
            if (cells[j].Contains(textContains))
                return "yes";
        }
    }
}
// if nothing found return "no"
return "no";
How can i make this code to look for EXACT MATCH?
For example, with the current code if i have in the table a keyword like
Test Keyword 2 test
And the next variable is like "Test Keyword 2"
it will tell me that this keyword already exist in the table.
How can i fix this?
 

LexxWork

Client
Регистрация
31.10.2013
Сообщения
1 190
Благодарностей
786
Баллы
113
change
if (cells[j].Contains(textContains))
to
if (cells[j] == textContains)
 
  • Спасибо
Реакции: convict29

convict29

Пользователь
Регистрация
10.07.2014
Сообщения
114
Благодарностей
3
Баллы
18
Thank you so much!
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)