本文整理汇总了C#中OrderedDictionary.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# OrderedDictionary.Remove方法的具体用法?C# OrderedDictionary.Remove怎么用?C# OrderedDictionary.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderedDictionary
的用法示例。
在下文中一共展示了OrderedDictionary.Remove方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Values_CopyTo
public void Values_CopyTo()
{
var dict = new OrderedDictionary<uint, int>();
dict.Add(1, 1);
dict.Add(2, 2);
dict.Add(3, 3);
dict.Remove(2);
dict.Add(4, 4);
int[] a = new int[13];
dict.Values.CopyTo(a, 10);
int v = 0;
for (int i = 0; i < 10; ++i)
{
if (i < 10)
Assert.AreEqual(default(int), a[i]);
}
Assert.AreEqual(1, a[10]);
Assert.AreEqual(3, a[11]);
Assert.AreEqual(4, a[12]);
}
示例2: Values_EnumerableOrder
public void Values_EnumerableOrder()
{
var dict = new OrderedDictionary<uint, int>();
dict.Add(1, 1);
dict.Add(2, 2);
dict.Add(3, 3);
dict.Remove(2);
dict.Add(4, 4);
Assert.AreEqual (1, dict.Values.ElementAt (0));
Assert.AreEqual (3, dict.Values.ElementAt (1));
Assert.AreEqual (4, dict.Values.ElementAt (2));
}
示例3: RemoveAt
public void RemoveAt()
{
var dict = new OrderedDictionary<uint, int>();
dict.Add(1, 1);
dict.Add(2, 2);
dict.Add(3, 3);
dict.Remove(2);
dict.Add(4, 4);
dict.RemoveAt (1);
Assert.AreEqual(1, dict[(int)0]);
Assert.AreEqual(4, dict[(int)1]);
}
示例4: Remove_KeyNull
public void Remove_KeyNull()
{
var dict = new OrderedDictionary<string, int>();
dict.Remove (null);
}
示例5: Remove
public void Remove()
{
var dict = new OrderedDictionary<string, int> { { "1", 2 }, { "2", 3 }, { "3", 4 } };
Assert.IsTrue(dict.Remove("2"));
Assert.IsFalse(dict.ContainsKey("2"));
Assert.IsFalse(dict.Values.Contains(3));
Assert.AreEqual(dict[1], 4);
Assert.IsFalse(dict.Remove("2"));
}
示例6: KeyIndexerSet
public void KeyIndexerSet()
{
var dict = new OrderedDictionary<uint, int>();
dict[(uint) 1] = 1;
dict[(uint)2] = 2;
dict[(uint)3] = 3;
dict.Remove (2);
dict[(uint)4] = 4;
Assert.AreEqual(1, dict[(int)0]);
Assert.AreEqual(3, dict[(int)1]);
Assert.AreEqual(4, dict[(int)2]);
}
示例7: EnumerableOrder
public void EnumerableOrder()
{
var dict = new OrderedDictionary<uint, int>();
dict.Add(1, 1);
dict.Add(2, 2);
dict.Add(3, 3);
dict.Remove(2);
dict.Add(4, 4);
using (var enumerator = dict.GetEnumerator())
{
Assert.IsTrue (enumerator.MoveNext());
Assert.AreEqual (1, enumerator.Current.Value);
Assert.IsTrue(enumerator.MoveNext());
Assert.AreEqual (3, enumerator.Current.Value);
Assert.IsTrue(enumerator.MoveNext());
Assert.AreEqual (4, enumerator.Current.Value);
}
}
示例8: CopyTo
public void CopyTo()
{
var dict = new OrderedDictionary<uint, int>();
dict.Add(1, 1);
dict.Add(2, 2);
dict.Add(3, 3);
dict.Remove(2);
dict.Add(4, 4);
KeyValuePair<uint, int>[] a = new KeyValuePair<uint, int>[13];
((ICollection<KeyValuePair<uint, int>>)dict).CopyTo (a, 10);
int v = 0;
for (int i = 0; i < 10; ++i)
{
if (i < 10)
Assert.AreEqual (default(KeyValuePair<uint, int>), a[i]);
}
Assert.AreEqual (1, a[10].Value);
Assert.AreEqual (3, a[11].Value);
Assert.AreEqual (4, a[12].Value);
}
示例9: RemoveItem
public void RemoveItem()
{
OrderedDictionary<string, string> dictionary = new OrderedDictionary<string, string>();
dictionary.Add("1", "one");
dictionary.Add("2", "two");
Assert.AreEqual(2, dictionary.Count);
// remove existing key
Assert.IsTrue(dictionary.Remove("1"));
Assert.AreEqual(1, dictionary.internalList.Count);
Assert.AreEqual(1, dictionary.internalDictionary.Count);
// remove non-existent key
Assert.IsFalse(dictionary.Remove("1")); // doesn't exist
Assert.AreEqual(1, dictionary.internalList.Count);
Assert.AreEqual(1, dictionary.internalDictionary.Count);
}