当前位置: 首页>>代码示例>>C#>>正文


C# OrderedDictionary.Remove方法代码示例

本文整理汇总了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]);
        }
开发者ID:mono,项目名称:rocks,代码行数:24,代码来源:OrderedDictionaryTest.cs

示例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));
        }
开发者ID:mono,项目名称:rocks,代码行数:13,代码来源:OrderedDictionaryTest.cs

示例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]);
        }
开发者ID:mono,项目名称:rocks,代码行数:14,代码来源:OrderedDictionaryTest.cs

示例4: Remove_KeyNull

 public void Remove_KeyNull()
 {
     var dict = new OrderedDictionary<string, int>();
     dict.Remove (null);
 }
开发者ID:mono,项目名称:rocks,代码行数:5,代码来源:OrderedDictionaryTest.cs

示例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"));
        }
开发者ID:mono,项目名称:rocks,代码行数:11,代码来源:OrderedDictionaryTest.cs

示例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]);
        }
开发者ID:mono,项目名称:rocks,代码行数:13,代码来源:OrderedDictionaryTest.cs

示例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);
            }
        }
开发者ID:mono,项目名称:rocks,代码行数:19,代码来源:OrderedDictionaryTest.cs

示例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);
        }
开发者ID:mono,项目名称:rocks,代码行数:24,代码来源:OrderedDictionaryTest.cs

示例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);
        }
开发者ID:johndkane,项目名称:GenericOrderedDictionary,代码行数:21,代码来源:OrderedDictionaryTester.cs


注:本文中的OrderedDictionary.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。