Link to home
Start Free TrialLog in
Avatar of gothic130
gothic130

asked on

Singly linked list

Hi, I have this code:

public class IntNodoLSL
    {
        public int info;
        public IntNodoLSL next;
        public IntNodoLSL(int i)
        {
            this(i, null);
        }
        public IntNodoLSL(int i, IntNodoLSL n)
        {
            info = i; next = n;
        }
    }

it creates a node for a singly linked list but in the line this(i,null) when I compile it it marks an error "Method name expected" what can be wrong?

Thank you!!!
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

try ...

this.IntNodoLSL(i, null);

also why write this when there is already a LinkedList<T> class? :)
Avatar of gothic130
gothic130

ASKER

Could you explain this:    "also why write this when there is already a LinkedList<T> class?"
maybe my problem is that I don't realy understand the code!

thank you!
I mean why write a SinglyLinked list when there is a class in the framework already that is a linkedlist :)
Could you tell me where is it???

:)
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you mat also want to look at List<T> which is a list implemented as a dynamically sized array.
whoops missed that they were constructors for your original question the answer to that is change it to ...


        public IntNodoLSL(int i) :  this(i, null);
        {
        }
You are right!!!!   Thank you very much!  It works now:

public IntNodoLSL(int i) :  this(i, null)
{
}