I have two classes:
SLList for methods (private SLElement _root)
SLElement for creating new elements for the list. (public int _value; public SLElement _next)
I have finished the add-method:
public void Add(int value)
{
SLElement addNewElement = new SLElement();
addNewElement._value = value;
SLElement rootCopy = _root;
_root = addNewElement;
addNewElement._next = rootCopy;
Console.WriteLine(addNewElement._value);
}
So now I want a remove-function. I already got it working that it removes an element with a specific value, but I want it so that it removes an element with an specific index. How can I find out the index of the elements in my list?
Loop throw index times and find the element