Friday, March 30, 2007

C#: ListNode

using System;
using System.Collections.Generic;
using System.Text;

namespace List
{
[Serializable]
class ListNode<T>
{
ListNode<T> next = null; //-- self referencing node
T data; //-- data segment
public ListNode(T t)
{
data = t;
}
public ListNode(T t, ListNode<T> n):this(t) //-- call the prev constructor 1st
{
//-- then proceed to following line
next = n;
}
public T Data{
get { return data; }
set { data = value; }
}
public ListNode<T> Next
{
get { return next; }
set { next = value; }
}
}
}

No comments: