Created
June 2, 2014 17:35
-
-
Save dannko/c62d98a151bcddafa493 to your computer and use it in GitHub Desktop.
Поиск текста в списке C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// берем из переменной текст, который надо искать | |
var textContains = project.Variables["gamefortext"].Value; | |
// получаем таблицу, в которой будем искать | |
var sourceTable = project.Tables["screenshots"]; | |
// ищем в каждой строчке в таблице | |
lock(SyncObjects.TableSyncer) | |
{ | |
for(int i=0; i < sourceTable.RowCount; i++) | |
{ | |
// читаем строку из таблицы (это будет массив ячеек) | |
var cells = sourceTable.GetRow(i).ToArray(); | |
// пройдем в цикле по всем ячейкам | |
for (int j=0; j < cells.Length; j++) | |
{ | |
// проверяем содержание текста в ячейке, если есть совпадение возвращаем "yes" | |
if (cells[j].Contains(textContains)) | |
return i; | |
} | |
} | |
} | |
// если ничего не нашли возвращаем "no" | |
return "54321"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment