C# | Get the number of nodes contained in LinkedList<T> Last Updated : 01 Feb, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report LinkedList<T>.Count property is used to get the number of nodes actually contained in the LinkedList<T>. Syntax: public int Count { get; } Return Value: The number of nodes actually contained in the LinkedList. Note: Retrieving the value of this property is an O(1) operation. Below given are some examples to understand the implementation in a better way: Example 1: CSHARP // C# code to get the number // of nodes actually contained // in the LinkedList using System; using System.Collections; using System.Collections.Generic; class GFG { // Driver code public static void Main() { // Creating a LinkedList of Strings LinkedList<String> myList = new LinkedList<String>(); // Adding nodes in LinkedList myList.AddLast("Geeks"); myList.AddLast("for"); myList.AddLast("Data Structures"); myList.AddLast("Noida"); // To get the number of nodes actually // contained in the LinkedList if (myList.Count > 0) Console.WriteLine(myList.Count); else Console.WriteLine("LinkedList is empty"); } } Output: 4 Example 2 : CSHARP // C# code to get the number // of nodes actually contained // in the LinkedList using System; using System.Collections; using System.Collections.Generic; class GFG { // Driver code public static void Main() { // Creating a LinkedList of Integers LinkedList<int> myList = new LinkedList<int>(); // To get the number of nodes actually // contained in the LinkedList if (myList.Count > 0) Console.WriteLine(myList.Count); else Console.WriteLine("LinkedList is empty"); } } Output : LinkedList is empty Reference: https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.linkedlist-1.count?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Get the number of nodes contained in LinkedList<T> S Sahil_Bansall Follow Improve Article Tags : C# CSharp-Generic-Namespace CSharp-LinkedList Similar Reads C# | Get the first node of the LinkedList<T> LinkedList<T>.First property is used to get the first node of the LinkedList<T>. Syntax: public System.Collections.Generic.LinkedListNode First { get; } Return Value: The first LinkedListNode<T> of the LinkedList<T>. Below given are some examples to understand the implementat 2 min read C# | Get the last node of the LinkedList<T> LinkedList<T>.Last property is used to get the last node of the LinkedList<T>. Syntax: public System.Collections.Generic.LinkedListNode Last { get; } Return Value: The last LinkedListNode<T> of the LinkedList<T>. Below given are some examples to understand the implementation 2 min read C# | Find the first node in LinkedList<T> containing the specified value LinkedList<T>.Find(T) method is used to find the first node that contains the specified value. Syntax: public System.Collections.Generic.LinkedListNode<T> Find (T value); Here, value is the value to locate in the LinkedList. Return Value: This method returns the first LinkedListNode<T 2 min read C# | Find the last node in LinkedList<T> containing the specified value LinkedList<T>.FindLast(T) method is used to find the last node that contains the specified value. Syntax: public System.Collections.Generic.LinkedListNode<T> FindLast (T value); Here, value is the value to locate in the LinkedList. Return Value: This method returns the last LinkedListNod 2 min read C# | Get the number of elements contained in Collection<T> Collection<T>.Count property is used to get the number of elements actually contained in the Collection<T>. Syntax: public int Count { get; } Return Value: The number of elements actually contained in the Collection<T>. Below given are some examples to understand the implementation 2 min read Like