Remove all elements from OrderedDictionary in CSharp
Description
The following code shows how to remove all elements from OrderedDictionary.
Example
using System;/*w w w .j a v a 2s.c om*/
using System.Collections;
using System.Collections.Specialized;
public class SamplesStringCollection {
public static void Main() {
OrderedDictionary myOrderedDictionary = new OrderedDictionary();
myOrderedDictionary.Add("testKey1", "testValue1");
myOrderedDictionary.Add("testKey2", "testValue2");
myOrderedDictionary.Add("testKey3", "testValue3");
Console.WriteLine(myOrderedDictionary.Count);
myOrderedDictionary.Clear();
Console.WriteLine(myOrderedDictionary.Count);
myOrderedDictionary.Add("newKey1", "newValue1");
myOrderedDictionary.Add("newKey2", "newValue2");
myOrderedDictionary.Add("newKey3", "newValue3");
Console.WriteLine(myOrderedDictionary.Count);
}
}
The code above generates the following result.