C# LinkedList<T>C# LinkedList<T> class uses the concept of linked list. It allows us to insert and delete elements fastly. It can have duplicate elements. It is found in System.Collections.Generic namespace. It allows us to add and remove element at before or last index. C# LinkedList<T> exampleLet's see an example of generic LinkedList<T> class that stores elements using AddLast() and AddFirst() methods and iterates elements using for-each loop. Output: John Sonoo Jaiswal Ankit Peter Irfan Note: Unlike List, you cannot create LinkedList using Collection initializer.C# LinkedList<T> example 2Let's see another example of generic LinkedList<T> class that stores elements before and after specific node. To get the specific node, we are calling Find() method. Output: Sonoo Ankit John Peter Lucy Irfan As you can see in the above output "John" and "Lucy" are added before and after "Peter". Next TopicC# Dictionary |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India