C#单向链表的实现
public class UserTbl
{
private string UserName;
public string UserName1
{
get { return UserName; }
set { UserName = value; }
}
public UserTbl(string aa)
{
this.UserName = aa;
}
public override string ToString()
{
return this.UserName1;
}
}
public class Nodes<T>
{
T data;
Nodes<T> next;
public Nodes(T data)
{
this.data = data;
this.next = null;
}
public T Data
{
get { return data; }
set { data = value; }
}
public Nodes<T> Next
{
get { return next; }
set { next = value; }
}
public void Append(Nodes<T> newNode)
{
if (newNode == null)
{
this.next = newNode;
}
else
{
this.next.Append(newNode);
}
}
public override string ToString()
{
string output = data.ToString();
if (next != null)
{
output += "," + next.ToString();
}
return output;
}
}
public class ListArray<T>
{
Nodes<T> headNode = null;
public void Add(T data)
{
if (data == null)
{
headNode = new Nodes<T>(data);
}
else
{
headNode.Append(new Nodes<T>(data));
}
}
public T this[int index]{
get
{
int ctr = 0;
Nodes<T> Node = headNode;
while (Node != null && ctr <= inde