Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get the count by type in a List

I am having trouble getting the count by its type.

Object

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How do I get the count of Home (PartnerIntegrationbTesting.Context.Home)? There are 4 items in the List (quoteList.Products)

>Solution :

Use .Count() with a filtering function. is will test if the left-hand object is the type specified on the right.

var countOfHomeProducts = quoteList.Products
   .Count(p => p is PartnerIntegrationbTesting.Context.Home);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading