N
N
nikvay2020-08-04 15:17:48
C++ / C#
nikvay, 2020-08-04 15:17:48

How to output a string from an array with the required character using LINQ?

Good afternoon!
There is an array of strings stingName with names. It is necessary to use LINQ methods to display strings that contain a character (for example, the character "a"). How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
twobomb, 2020-08-04
@nikvay

stingName.Where(s => s.Contains("a")).ToList().ForEach(s => Console.WriteLine(s));

F
freeExec, 2020-08-04
@freeExec

Console.WriteLine(string.Join(", ", stingName.Where(s => s.Contains('a')).ToArray()));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question