Data Structures in C# (Implement a linkedlist)

In Mosh’s video he uses Java and is able to overcome the accessibility issue by placing the Node class within the LinkedList class. In C# however the private fields (value & next) of the Node class are still inaccessible even after relocating the Node class, and so I’ve been making the fields public.

What is the go to implementation/workaround for building a LinkedList in C#?

That’s totally fine. Since the Node class is private it’s still an implementation detail invisible from outside the LinkedList class. The semantics of private are just a little different in C# compared to Java and IMHO more reasonable.

1 Like

Thanks much for the clarification