- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a generic List in C#?
Generic List<T> is a generic collection in C#. The size can be dynamically increased using List, unlike Arrays.
Let us see an example −
We have set the List first −
List<string> myList = new List<string>()
Now add elements in the list −
List<string> myList = new List<string>() { "mammals", "reptiles", "amphibians" }
Now using a property let us count the number of elements added −
Example
using System; using System.Collections.Generic; class Program { static void Main() { List<string> myList = new List() { "mammals", "reptiles", "amphibians" }; Console.WriteLine(myList.Count); } }
- Related Articles
- How to clone a generic list in C#?
- What are generic methods in C#?
- What are generic features in C#?
- What are generic collections in C#?
- What are generic delegates in C#?
- Generic keyword in C ?
- What is Generic Routing Encapsulation (GRE)?
- What is the generic functional interface in Java?
- Func generic type in C#
- How to store n number of lists of different types in a single generic list in C#?
- How to deserialize a JSON array to list generic type in Java?
- Convert array to generic list with Java Reflections
- What are generic methods in Java?
- Non-generic Vs Generic Collection in Java
- Defining generic method inside Non-generic class in Java

Advertisements