0

Hey,
How would I go about finding the amount of values, say "DaniWeb" in a List<string>? I just need a number, not their index.
Cheers

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by bbman
0

Sorted, the answer (for anyone interested) was:

List.Count(c => c == "DaniWeb");
0

Hey,
How would I go about finding the amount of values, say "DaniWeb" in a List<string>? I just need a number, not their index.
Cheers

What do you mean "amount of values"? I don't understand the question.

Nevermind, BBman obviously understood. :)

Edited by Zinderin: n/a

0

Hey,
How would I go about finding the amount of values, say "DaniWeb" in a List<string>? I just need a number, not their index.
Cheers

Hi bbman,

The simplest way of achieving this would be a simple "for" or "foreach" loop.

int countFoo = 0;
foreach (string strSomething in listSomething)
{
    if(strSomething == "foo") countFoo++;
}

Vasiliy

0

Cheers for the replies, but it's already sorted out. The best method was what I posted.
Cheers.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.