Answer the question
In order to leave comments, you need to log in
How to find the index of an element of a one-dimensional array with a full name by last name?
Hello.
The essence of the task - there is an array with the full name of the employees:
let's say string [] array = { "Ivanov Ivan Ivanovich", "Sidorov Sidor Sidorovich", "Petrov Petr Petrovich",};
you need to do a search by last name, so that when you enter from the keyboard: Ivanov, it returns the full name.
As I understand it, you need to check all elements for similarity and, having received the index of a similar one, display it on the screen.
The problem is in finding a similar one, I tried Array.Indexof () - it doesn’t work, it searches only for the full name.
P.S. according to the condition of the problem, we have 1 array with full name, cannot be split into 3 with separate last name, first name and patronymic.
Answer the question
In order to leave comments, you need to log in
string[] array = { "Иванов Иван Иванович", "Сидоров Сидор Сидорович", "Петров Петр Петрович" };
var find = "сид";
var finded = array.Where(v => v.Split(' ')[0].ToLower().Contains(find)).ToList();//[0] Сидоров Сидор Сидорович
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question