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


C# Dictionary.Skip方法代码示例

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


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

示例1: SkipShouldTrimDictionary

        public void SkipShouldTrimDictionary()
        {
            // arrange
            var target = new Dictionary<string, int>()
            {
                { "Key1", 1 },
                { "Key2", 2 },
                { "Key3", 3 },
                { "Key4", 4 },
                { "Key5", 5 }
            };

            // act
            var actual = target.Skip( "Key2", "Key4" );

            // assert
            Assert.Equal( 3, actual.Count );
            Assert.True( actual.ContainsKey( "Key1" ) );
            Assert.False( actual.ContainsKey( "Key2" ) );
            Assert.True( actual.ContainsKey( "Key3" ) );
            Assert.False( actual.ContainsKey( "Key4" ) );
            Assert.True( actual.ContainsKey( "Key5" ) );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:23,代码来源:IDictionaryExtensionsTest.cs

示例2: should_map_non_generic_dictionary_to_generic_enumerable_of_dictionary_entry

        public void should_map_non_generic_dictionary_to_generic_enumerable_of_dictionary_entry()
        {
            var results = new Dictionary<string, object>
                {{"oh", 1}, {"hai", 2}}.As<IDictionary>().AsEnumerable();
            results.ShouldTotal(2);

            var result = results.First();
            result.ShouldBeType<DictionaryEntry>();
            result.Key.ShouldEqual("oh");
            result.Value.ShouldEqual(1);

            result = results.Skip(1).First();
            result.ShouldBeType<DictionaryEntry>();
            result.Key.ShouldEqual("hai");
            result.Value.ShouldEqual(2);
        }
开发者ID:mikeobrien,项目名称:Bender,代码行数:16,代码来源:LinqExtensionTests.cs

示例3: LoadInputFile

        private static InputFile LoadInputFile(string filePath)
        {
            var fileRowData = new Dictionary<int, IRow>();

            using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                int index = 0;
                var uploadedExcel = new XSSFWorkbook(fs);
                //get data sheet
                ISheet dataSheet = uploadedExcel.GetSheetAt(0);
                // preload into memory and close the stream
                IEnumerator rowEnumerator = dataSheet.GetEnumerator();
                while (rowEnumerator.MoveNext())
                {
                    fileRowData.Add(index, (IRow) rowEnumerator.Current);
                    index++;
                }
            }
            //take header rows
            List<IRow> header = fileRowData.Take(1).ToList().ConvertAll(x => x.Value);
            //skip header rows
            List<ProductInputRow> productInputRowData =
                fileRowData.Skip(1).ToList().ConvertAll(x => Converter.Convert(x.Value, x.Key, header.Last()))
                    .Where(x => !x.AllStringPropertiesNullOrEmpty())
                    // filter out blanked out data: NPOI reads them as rows
                    .ToList();
            return new InputFile {Header = header, Data = productInputRowData};
        }
开发者ID:aleks279,项目名称:atrend-test,代码行数:28,代码来源:ProductUploader.cs


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