How do I cound the number of items in a List
List
Perhaps something similar to -> liststCarColors.FindAll("Blue")?
How do I cound the number of items in a List
List
Perhaps something similar to -> liststCarColors.FindAll("Blue")?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Cr BhargaviPosted Feb 21, 2024, 6:24 AM
Snigdha RathPosted Feb 21, 2024, 5:49 AM
You can count the number of items in a List that contain the word "blue" using LINQ's
Countmethod along with a lambda expression. For example:Jignesh KumarPosted Feb 21, 2024, 4:07 AM
Please check this one,
Add linq reference,
using System.Linq;
Aravind GovindarajPosted Feb 20, 2024, 7:05 PM
If you are doing wildcard matching, then please use this snippet
int count = itemList.Count(item => item.Contains("blue"));
if you are looking exact match then please follow the below snippet
int count = itemList.Count(item => item == "blue");