
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to count the number of items in a C# list?
Use the Array.Count property in C# to count the number of items in a list in C# −
Set the list
List<string> myList = new List<string>() { "electronics", "clothing", "appliances", "accessories" };
Now count the number of items in a list in C# −
myList.Count
The following is the complete code to count the number of items in a list −
Example
using System; using System.Collections.Generic; class Program { static void Main() { List myList = new List() { "electronics", "clothing", "appliances", "accessories" }; Console.WriteLine(myList.Count); } }
- Related Questions & Answers
- Count number of items in a dictionary value that is a list in Python
- Count the number of items in an array in MongoDB?
- How to randomize the items of a list in Python?
- How to add items to a list in C#?
- Python - Create nested list containing values as the count of list items
- Count the total number of elements in the List in C#?
- How to remove items from a list in C#?
- Golang Program to count the number of nodes in a linked list.
- Distinct number of specific items in list with MySQL
- Golang program to count the number of nodes in a doubly linked list.
- How to count total number of occurrences of an object in a Python list?
- MongoDB query to count the number of array items in documents and display in a new field
- C# program to count the number of words in a string
- C# Program to count the number of lines in a file
- C Program to count the number of lines in a file?
Advertisements