148
C# List<T>
C# List<T> class is used to store and fetch elements. It can have duplicate elements. It is found in System.Collections.Generic namespace.
C# List<T> example
Let’s see an example of generic List<T> class that stores elements using Add() method and iterates the list using for-each loop.
Output:
tutor aspire Ankit Peter Irfan
C# List<T> example using collection initializer
Output:
tutor Vimal Ratan Love
Next TopicC# HashSet