static void asksomethinglater(IntNode b)//
{
IntNode temp = b;
b = b.GetNext();
temp.SetNext(null);
}
I have this code that should upadte the argument b, but when ever i run this, i have this object as an example IntNode b = new IntNode(3, new IntNode(5, new IntNode(2)));
The object will have only 5, with this.next = null
the class i use.
public class IntNode
{
private int info;
private IntNode next;
public IntNode(int info)
{
this.info = info;
this.next = null;
}
public IntNode(int info, IntNode next)
{
this.info = info;
this.next = next;
}
public int GetInfo()
{
return info;
}
public IntNode GetNext()
{
return next;
}
public void SetInfo(int info)
{
this.info = info;
}
public void SetNext(IntNode next)
{
this.next = next;
}
public override string ToString()
{
if(next != null)
return info + "-->" + next;
return info.ToString();
}
}
}