Skip to end of metadata
Go to start of metadata

I made a singly linked list in C# for this project. Each node has data and a next pointer, and the list has a head, tail, and size. I used a generic type again for this, meaning that it has the same benefits and drawbacks as in C++ (see my C++ Project 5 page). I tested my linked list using ints and strings in this program. For the string test, the ll_map input function I used was one that turns the string into itself but repeated (e.g. "A" becomes "AA"). Below is a picture of the Node and LinkedList classes, with two of the methods from LinkedList.

I needed to define a delegate method type that can serve as the input to the ll_map function. I also needed said input functions to have ref type input to be able to directly modify the data in nodes; this is similar to pointers in C and C++. Below are the compare function, which is used to find matches when removing a node, and the two methods that modify nodes through ll_map.

The main types of polymorphism in C# are static polymorphism (function and operator overloading) and dynamic polymorphism (using keywords "static" and "virtual").

  • No labels