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!!!
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!!!
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!
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 :)
ASKER
Could you tell me where is it???
:)
:)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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);
{
}
public IntNodoLSL(int i) : this(i, null);
{
}
ASKER
You are right!!!! Thank you very much! It works now:
public IntNodoLSL(int i) : this(i, null)
{
}
public IntNodoLSL(int i) : this(i, null)
{
}
this.IntNodoLSL(i, null);
also why write this when there is already a LinkedList<T> class? :)