C# | ASP.NET/C#
C# LinkedList Example
bboks.net
2010. 3. 23. 11:51
LinkedList<Node> list = new LinkedList<Node>();
list.AddLast(new Node(3.5));
list.AddLast(new Node(3.6));
list.AddLast(new Node(3.7));
list.AddLast(new Node(3.8));
list.AddLast(new Node(3.9));
list.AddLast(new Node(3.5));
list.AddLast(new Node(3.6));
list.AddLast(new Node(3.7));
list.AddLast(new Node(3.8));
list.AddLast(new Node(3.9));
Node selectedNode = list.ElementAt(4);
LinkedListNode<Node> node = list.Find(selectedNode);
list.AddAfter(node, new Node(2.1));
for (int i = 0; i < list.Count; i++)
{
System.Console.WriteLine(list.ElementAt(i).GetValue());
}
//custom class
class Node
{
double value;
public Node(double value)
{
this.value = value;
}
public double GetValue()
{
return value;
}
public void SetValue(double value)
{
this.value = value;
}
}