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


C# System.Collections.Generic.Reverse方法代码示例

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


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

示例1: IntervalTimePerTimeValuesAttribute

        static IntervalTimePerTimeValuesAttribute()
        {
            var values = new List<IQuantity>();

            var times = new[]
            {
                //TODO: ... however, us, ms, s, min, hr, are not unreasonable to expect ...
                T.Microsecond,
                T.Millisecond,
                T.Second,
                T.Minute,
                T.Hour,
                ////TODO: we do not care about Days or Weeks for purposes of these tests...
                //T.Day,
                //T.Week,
            };

            // TODO: TBD: Avoid scaling too absurdly: may want to be more selective than this...
            var length = times.Length - 2;

            // TODO: TBD: Could also vary the value itself, but this will do for starters...
            const double value = 1e2;

            var first = times.Take(length).ToArray();
            var second = times.Reverse().Take(length).ToArray();

            values.AddRange(from x in first from y in second select new Quantity(value, x, y.Invert()));
            values.AddRange(from y in first from x in second select new Quantity(value, x, y.Invert()));

            Values = values.OfType<object>().ToArray();
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:31,代码来源:IntervalTimePerTimeValuesAttribute.cs

示例2: Execute

        public void Execute()
        {
            IEnumerable<int> numbers = new[] {1, 2, 3, 4, 5};
            IEnumerable<Person> persons = new List<Person>
            {
                new Person {Id = 1001, Name = "gsf_zero1"},
                new Person {Id = 1000, Name = "gsf_zero2"},
                new Person {Id = 111, Name = "gsf_zero3"},
                new Person {Id = 9889, Name = "gsf_zero4"},
                new Person {Id = 9889, Name = "gsf_zero5"},
                new Person {Id = 100, Name = "gsf_zero6"}
            };

            //
            // Reverse拡張メソッドは、文字通りソースシーケンスを逆順に変換するメソッドである。
            // このメソッドは、そのままソースシーケンスを逆順に変換するだけである。
            //
            // 尚、本メソッドは、他のLINQ演算子と同様に遅延実行される。
            //
            var reverseNumbers = numbers.Reverse();
            var reversePersons = persons.Reverse();

            Output.WriteLine(string.Join(",", reverseNumbers.Select(element => element.ToString())));
            Output.WriteLine(string.Join(",", reversePersons.Select(element => element.ToString())));
        }
开发者ID:devlights,项目名称:Sazare,代码行数:25,代码来源:LinqSamples24.cs

示例3: SortedSet_ShouldStoreTextRangesByPosition_WhenPositionComparerIsUsed

        public void SortedSet_ShouldStoreTextRangesByPosition_WhenPositionComparerIsUsed()
        {
            // Given
            var text = "one,two,three,four";
            var textRanges = new[]
            {
                new TextRange(0, 3),
                new TextRange(5, 7),
                new TextRange(9, 13),
                new TextRange(15, 18),
            };

            var underTest = new SortedList<TextRange, TextRange>(TextRange.PositionComparer);

            // When
            foreach (var textRange in textRanges.Reverse())
            {
                underTest.Add(textRange, textRange);
            }

            // Then
            var actual = underTest.Values.SequenceEqual(textRanges);
            Assert.That(actual, Is.True);
        }
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:24,代码来源:TextRangeTests.cs

示例4: FormatValue

        /// <summary>
        /// Returns the pretty printed value
        /// </summary>
        /// <param name="value">The sum to pretty print</param>
        /// <returns></returns>
        public string FormatValue(decimal value)
        {
            var nfi = new NumberFormatInfo
            {
                NumberDecimalSeparator = DecimalSeparator,
                NumberGroupSeparator = ThousandsSeparator,
                NumberDecimalDigits = DecimalDigits
            };

            var v = value.ToString("N", nfi);
            var space = SpaceBetweenAmountAndSymbol ? " " : "";

            IEnumerable<string> parts = new[] { v, space, Symbol };

            if (SymbolOnLeft)
            {
                parts = parts.Reverse();
            }

            return string.Join("", parts);
        }
开发者ID:jochenvanwylick,项目名称:SkyScanner,代码行数:26,代码来源:Currency.cs


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