Remove all nodes from LinkedList in CSharp
Description
The following code shows how to remove all nodes from LinkedList.
Example
//from w w w . j av a 2s .c o m
using System;
using System.Collections;
using System.Collections.Generic;
public class GenericCollection
{
public static void Main()
{
LinkedList<String> ll = new LinkedList<String>();
ll.AddLast( "A" );
ll.AddLast( "B" );
ll.AddLast( "C" );
ll.AddLast( "java2s.com" );
Console.WriteLine(ll.Count);
ll.Clear();
Console.WriteLine(ll.Count);
}
}
The code above generates the following result.