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


C# OrderedDictionary.RemoveAt方法代码示例

本文整理汇总了C#中OrderedDictionary.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# OrderedDictionary.RemoveAt方法的具体用法?C# OrderedDictionary.RemoveAt怎么用?C# OrderedDictionary.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrderedDictionary的用法示例。


在下文中一共展示了OrderedDictionary.RemoveAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveAt_IndexOutOfRangeLower

        public void RemoveAt_IndexOutOfRangeLower()
        {
            var dict = new OrderedDictionary<string, int>();
            dict.Add("foo", 0);
            dict.Add("bar", 1);
            dict.Add("baz", 2);

            dict.RemoveAt (-1);
        }
开发者ID:mono,项目名称:rocks,代码行数:9,代码来源:OrderedDictionaryTest.cs

示例2: TransformAsyncMethod


//.........这里部分代码省略.........
                            // check for exceptions
                            current.Add (inst2); // Ldarg.0
                            current.Add (il.Create (OpCodes.Ldfld, chainedFld));
                            current.Add (il.Create (OpCodes.Call, getException));
                            current.Add (il.Create (OpCodes.Brfalse, inst));

                            // houston, we have an exception..
                            //if (hasCatch) {
                            // OpCodes.Call, $catch1
                            // ...
                            // } else {
                            current.Add (il.Create (OpCodes.Ldarg_0));
                            current.Add (il.Create (OpCodes.Ldarg_0));
                            current.Add (il.Create (OpCodes.Ldfld, chainedFld));
                            current.Add (il.Create (OpCodes.Call, getException));
                            current.Add (il.Create (OpCodes.Call, setException));
                            // }
                            // if (hasFinally)
                            //  OpCodes.Call, $finally1
                            // if (!hasCatch)
                            current.Add (il.Create (OpCodes.Ret));

                            current.Add (inst); // Nop
                            coroutineInstructions.Add (inst, current);

                            i = coroutineInstructions.IndexOfKey (continuationInst);
                            while (continuationInst != lastStack) {
                                // move these to after the continuation
                                // FIXME: Currently, we can't handle any jumps into this critical area
                                if (method.Body.IsJumpTarget (continuationInst))
                                    throw new NotSupportedException ("Support for jumps into continuation critical area not implemented");

                                current = coroutineInstructions [i];
                                coroutineInstructions.RemoveAt (i);
                                coroutineInstructions.Add (continuationInst, current);

                                continuationInst = coroutineInstructions.KeyForIndex (++i);
                            }

                            // load the continuation result if there is one

                            var waitFutureType = callee.DeclaringType as GenericInstanceType;
                            if (waitFutureType != null) {
                                var getValueMethod = module.Import (typeof (Future<>).GetProperty ("Value").GetGetMethod (), waitFutureType);
                                getValueMethod.DeclaringType = waitFutureType;

                                current = new List<Instruction> ();
                                current.Add (il.Create (OpCodes.Ldarg_0));
                                current.Add (il.Create (OpCodes.Ldfld, chainedFld));
                                current.Add (il.Create (OpCodes.Call, getValueMethod));
                                coroutineInstructions.Add (instruction, current);
                            }

                            continue;
                        }

                        //5
                        if (callee.Name == "op_Implicit" && callee.DeclaringType.IsBuiltInFutureType ()
                            && instruction.Next.OpCode == OpCodes.Ret)
                            continue;

                        //6
                        if (callee.Name == "Yield" && callee.DeclaringType.FullName == "Cirrus.Thread") {
                            var inst = il.Create (OpCodes.Ret);
                            continuations.Add (inst);
开发者ID:chkn,项目名称:cirrus,代码行数:66,代码来源:TargetIL_old.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: RemoveAt

        public void RemoveAt()
        {
            OrderedDictionary<string, string> dictionary = new OrderedDictionary<string, string>();

            // put two items in dictionary
            dictionary.Add("1", "one");
            dictionary.Add("2", "two");

            Assert.AreEqual(2, dictionary.Count);

            // remove at first index (leaves one)
            dictionary.RemoveAt(0);

            Assert.AreEqual(1, dictionary.internalList.Count);
            Assert.AreEqual(1, dictionary.internalDictionary.Count);
            Assert.AreEqual("2", dictionary[0].Key);

            // remove at non-existent index
            Assert.Throws(
                typeof(ArgumentOutOfRangeException),
                delegate() { dictionary.RemoveAt(1); }
                ); // doesn't exist

            Assert.AreEqual(1, dictionary.internalList.Count);
            Assert.AreEqual(1, dictionary.internalDictionary.Count);

            // remove remaining item at first index
            dictionary.RemoveAt(0);

            Assert.AreEqual(0, dictionary.internalList.Count);
            Assert.AreEqual(0, dictionary.internalDictionary.Count);
        }
开发者ID:johndkane,项目名称:GenericOrderedDictionary,代码行数:32,代码来源:OrderedDictionaryTester.cs


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