Size of a LinkedList in C#

c#, linked-list, size

Solution

You want to use the `Count` property.

Additionally, `LinkedList` implements `IEnumerable`, so all methods for that interface are also avaliable, including `Count()`.

Problem

I am porting a Java program to C#. In Java to get the size of a `LinkedList<T>` I do: `int size = list.size();` However, I cannot find a similar method in C#. I know that the point of a linked list is not to know the size of it, but since I am using it for a buffer it would be a good idea to have a counter internally in the list to return its size.

Original source