c#

位置:IT落伍者 >> c# >> 浏览文章

C#单链表


发布日期:2021年11月16日
 
C#单链表

using System;

using SystemCollectionsGeneric;

using SystemText;

namespace bishi

{

public class Node

{

public object element;

public Node link;

public Node()

{

element = null;

link = null;

}

public Node(object item)

{

element = item;

thislink = null;

}

}

public class LinkList

{

public Node head;

public LinkList Next;

public LinkList()

{

head = new Node(header);

}

public Node findNode(object item)

{

Node current = new Node();

current=head;

while (currentelement != item)

{

current = currentlink;

}

return current;

}

public void insertNode(object itemobject after)

{

Node current = new Node();

Node newNode=new Node(item);

current = findNode(after);

if (current != null)

{

newNodelink = currentlink;

currentlink = newNode;

}

}

public void Del(object item)

{

Node current = new Node();

current = findPre(item);

Node pre = new Node();

// Node after = new Node();

if (current != null)

currentlink = currentlinklink;

}

public Node findPre(object item)

{

Node current = head;

while (!(currentlinkelement != item) && (currentlink != null))

{

current = currentlink;

}

return current;

}

public void PrintList()

{

Node current = new Node();

current = thishead;

while (current != null)

{

ConsoleWriteLine(currentelement);

current = currentlink;

}

}

}

class pro

{

static void Main(string[] args)

{

Node firstNode = new Node(firstNode);

Node secNode = new Node(secNode);

Node thiNode = new Node();

firstNodelink = secNode;

secNodelink = thiNode;

thiNodelink = null;

LinkList myList = new LinkList();

myListheadlink = firstNode;

myListPrintList();

myListinsertNode(hanwujibabyfirstNode);

myListPrintList();

myListDel(hanwujibaby);

myListPrintList();

SystemThreadingThreadSleep();

}

}

}

               

上一篇:.net程序员应该掌握的常用类库

下一篇:C#创建SQL Server数据库浅析