T
T
tera10042019-01-20 19:01:26
C++ / C#
tera1004, 2019-01-20 19:01:26

What does the Count method do in this case?

There is a part of the program code.

foreach (var line in lines)
            {
                int vowels_count = line.Count(x => vowels.Contains(x));
                int consonants_count = line.Count(x => consonants.Contains(x));
                if (vowels_count > consonants_count)
                    Console.WriteLine(line);

Can you explain what it does in the line
int vowels_count = line.Count(x => vowels.Contains(x));

line.count , x => vowels.Contains(x)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-01-20
@WNeZRoS

It does the same as the following code:

int vowels_count = 0;
foreach(var x in line)
{
    if (vowels.Contains(x))
        vowels_count++;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question