N
N
Nikolai Novosad2016-01-27 02:34:42
C++ / C#
Nikolai Novosad, 2016-01-27 02:34:42

Substring search?

Hello.
Please tell me why file search is not working. If you enter a substring that is in the first line into the textbox, then it works. Otherwise, no.

// поиск
private void button3_Click(object sender, EventArgs e)
{
string searchText = textBox4.Text;
string[] arr = System.IO.File.ReadAllLines("football.txt", Encoding.Default);
dataGridView1.DataSource = MakeList(arr, searchText);
}

// реализация поиска
static List<Uefa> MakeList(string[] array, string searchText)
{
List<Uefa> list = new List<Uefa>();

for (int i = 0; i < array.Length; i++)
{
if (array[i].Contains(searchText))
{
string[] temp = array[i].Split(' ');
list.Add(new Uefa(list.Count + 1, temp[0], temp[1], temp[2], Convert.ToInt32(temp[3]), Convert.ToInt32(temp[4]), Convert.ToInt32(temp[5])));
}
}
return list;
}

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question