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


C# System.Linq.Max方法代码示例

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


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

示例1: Execute

        public void Execute()
        {
            var numbers = new[]
            {
                1, 2, 3, 4, 5, 0, 10, 98, 99
            };

            //
            // Min, Max拡張メソッドは、文字通り最小値、最大値を求める拡張メソッド。
            //
            // Min, Max拡張メソッドには、各基本型のオーバーロードが用意されており
            // (decimal, double, int, long, single及びそれぞれのNullable型)
            // それぞれに、引数無しとselectorを指定するバージョンのメソッドがある。
            //

            //
            // 引数無しのMin, Max拡張メソッドの使用.
            //
            Output.WriteLine("引数無し[Min] = {0}", numbers.Min());
            Output.WriteLine("引数無し[Max] = {0}", numbers.Max());

            //
            // selectorを指定するMin, Max拡張メソッドの使用.
            //
            Output.WriteLine("引数有り[Min] = {0}", numbers.Min(item => item%2 == 0 ? item : 0));
            Output.WriteLine("引数有り[Max] = {0}", numbers.Max(item => item%2 == 0 ? item : 0));
        }
开发者ID:devlights,项目名称:Sazare,代码行数:27,代码来源:LinqSamples34.cs

示例2: Execture_HomeAutomationSingleDeviceDefinition

        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var interpreter = context.Interpreter;
            var device = context.Device as OpenZWaveDevice;

            var headers = new[]
            {
                "Command Class",
                "Index",
                "Instance",
                "Value",
                "Units",
                "Type",
                "Label",
                "Help"
            };

            var values = device.Values
                               .OrderBy(x => x.Index)
                               .OrderBy(x => x.Instance)
                               .OrderBy(x => x.CommandClass.ToString());

            var rows = values.Select(TransformValue).ToArray();

            var rowsAndHeaders = new[] {headers}.Concat(rows).ToArray();

            var columnWidths = new int[headers.Length];

            for (var i = 0; i < columnWidths.Length; i++)
            {
                columnWidths[i] = rowsAndHeaders.Max(x => x[i].Length);
            }

            var tableBuilder = new TextTable(columnWidths);

            interpreter.WriteEvent(tableBuilder.StartOfTable(headers));

            foreach (var row in rows)
            {
                interpreter.WriteEvent(tableBuilder.ContentLine(row));
            }

            interpreter.WriteEvent(tableBuilder.EndOfTable());
        }
开发者ID:Mavtak,项目名称:roomie,代码行数:44,代码来源:PrintData.cs

示例3: MeasureOverride

        protected override Size MeasureOverride(Size availableSize)
        {
            var bounds = new Rect();
            var midPoint = new Point(0, 0);
            var arc = new Arc(midPoint, this.MinAngle, this.MaxAngle, this.ReservedSpace, this.IsDirectionReversed);
            for (int i = 0; i < this.AllTicks.Count; i++)
            {
                var tick = this.AllTicks[i];
                var text = this.AllTexts[i];
                var angle = TickHelper.ToAngle(tick, this.Minimum, this.Maximum, arc);
                var point = arc.GetPoint(angle);
                var textPosition = new TextPosition(text, new TextPositionOptions(this.TextOrientation, angle), point, angle);
                bounds.Union(textPosition.TransformedBounds);
            }
            var points = new[] { bounds.TopLeft, bounds.TopRight, bounds.BottomRight, bounds.BottomLeft };

            this.TextSpace = 2 * points.Max(p => (p - midPoint).Length);
            return bounds.Size;
        }
开发者ID:JackWangCUMT,项目名称:Gu.Gauges,代码行数:19,代码来源:AngularTextBar.cs

示例4: GetHighwaysAroundATrace


//.........这里部分代码省略.........
         new Coordinate(35.0770782681049, 31.7484148491295),
         new Coordinate(35.0772152594454, 31.7485682999149),
         new Coordinate(35.0773945410268, 31.7486676819746),
         new Coordinate(35.0775315332608, 31.7488211324163),
         new Coordinate(35.0777213696559, 31.7489205245313),
         new Coordinate(35.0779112309998, 31.7490018794643),
         new Coordinate(35.0781116344313, 31.7490922630334),
         new Coordinate(35.0782803517274, 31.7492006518231),
         new Coordinate(35.0784279369092, 31.749327056402),
         new Coordinate(35.0785966305898, 31.7494534816689),
         new Coordinate(35.0787547584758, 31.7495889147441),
         new Coordinate(35.0789128868221, 31.7497243476215),
         new Coordinate(35.0790499074385, 31.7498597595188),
         new Coordinate(35.0791552296681, 31.7500221954664),
         new Coordinate(35.079271118537, 31.7501756232497),
         new Coordinate(35.0793342006427, 31.7503560544372),
         new Coordinate(35.0794184034622, 31.7505274878662),
         new Coordinate(35.07948148609, 31.7507079189722),
         new Coordinate(35.0795762437083, 31.7508793626449),
         new Coordinate(35.0796815559056, 31.7510508165839),
         new Coordinate(35.0797657720828, 31.751213231321),
         new Coordinate(35.0798288558452, 31.7513936622385),
         new Coordinate(35.0799236147985, 31.7515651056378),
         new Coordinate(35.0800078197918, 31.7517365386504),
         new Coordinate(35.0800920130332, 31.7519169900494),
         new Coordinate(35.0801550979012, 31.7520974207882),
         new Coordinate(35.0802287373828, 31.7522778617867),
         new Coordinate(35.080344618785, 31.7524403069963),
         new Coordinate(35.0804921998805, 31.7525757275856),
         new Coordinate(35.0805658524078, 31.7527471499334),
         new Coordinate(35.0807239767497, 31.7528915989612),
         new Coordinate(35.0808398717683, 31.7530450252643),
         new Coordinate(35.0809768761181, 31.7531984719274),
         new Coordinate(35.0811033144633, 31.7533609266626),
         new Coordinate(35.0812191987379, 31.7535233710565),
         new Coordinate(35.0813562282957, 31.7536587804158),
         new Coordinate(35.0814509923604, 31.7538302226312),
         new Coordinate(35.0815668897444, 31.7539836482564),
         new Coordinate(35.0816616545267, 31.7541550903082),
         new Coordinate(35.0817564196575, 31.7543265322858),
         new Coordinate(35.0819357171872, 31.7544259079069),
         new Coordinate(35.0820516042382, 31.7545883515235),
         new Coordinate(35.0821675035548, 31.7547417765889),
         new Coordinate(35.0822411608737, 31.7549131979221),
         new Coordinate(35.0823676155936, 31.755066632928),
         new Coordinate(35.0824835160256, 31.7552200576973),
         new Coordinate(35.0825677172042, 31.7554005073817),
         new Coordinate(35.0826519423383, 31.7555629201228),
         new Coordinate(35.0827784104194, 31.7557073362678),
         new Coordinate(35.0828837457549, 31.7558697690173),
         new Coordinate(35.0829679600791, 31.7560411999812),
         new Coordinate(35.0830838509386, 31.7562036426272),
         new Coordinate(35.0832420085743, 31.7563300515947),
         new Coordinate(35.083442491669, 31.7563753345247),
         new Coordinate(35.0836641197941, 31.7563935818417),
         new Coordinate(35.0838857129203, 31.756438884096),
         new Coordinate(35.0840967630902, 31.7564751575489),
         new Coordinate(35.0843183566239, 31.7565204590512),
         new Coordinate(35.0845188639271, 31.7565477034066),
         new Coordinate(35.0847298913663, 31.7566020126932),
         new Coordinate(35.0849091964647, 31.7567013841131),
         new Coordinate(35.0850779123208, 31.7568278007081),
         new Coordinate(35.0852889291647, 31.7568911275094),
         new Coordinate(35.0854365360624, 31.7570175238719),
         new Coordinate(35.0856052647388, 31.757134921325),
         new Coordinate(35.0857845602899, 31.7572433099498),
         new Coordinate(35.0859532783201, 31.7573697253802),
         new Coordinate(35.0860903319162, 31.7574961111571),
         new Coordinate(35.0862590508207, 31.7576225261797),
         new Coordinate(35.0863960937519, 31.7577579300644),
         new Coordinate(35.0865754028623, 31.7578572991312),
         new Coordinate(35.0867547123563, 31.7579566679449),
         new Coordinate(35.0869551550878, 31.7580380191071),
         new Coordinate(35.0871555981708, 31.7581193699537),
         new Coordinate(35.0873243423818, 31.7582277466806),
         new Coordinate(35.0875247748542, 31.7583181153851),
         new Coordinate(35.0876935085294, 31.7584355100609),
         new Coordinate(35.0878833867277, 31.7585258685215),
         new Coordinate(35.0880838655461, 31.7585801625885),
         new Coordinate(35.0882843107889, 31.7586615116576),
         new Coordinate(35.0885059565864, 31.758670732122),
         new Coordinate(35.0887065820637, 31.7586077854993),
         new Coordinate(35.0888966746076, 31.7585267921022),
         new Coordinate(35.0890762453278, 31.7584187335373),
         new Coordinate(35.089276869878, 31.7583557860119),
         new Coordinate(35.0894880269069, 31.7583108845794)
     };
     var highways = _gateway.GetHighways(new LatLng
     {
         lat = coordinates.Max(c => c.Y),
         lng = coordinates.Max(c => c.X)
     }, new LatLng
     {
         lat = coordinates.Min(c => c.Y),
         lng = coordinates.Min(c => c.X)
     }
     ).Result;
     highways = _gateway.GetHighwaysAroundATrace(coordinates).Result;
     Assert.AreEqual(66, highways.Count);
 }
开发者ID:IsraelHikingMap,项目名称:Site,代码行数:101,代码来源:OverpassGatewayTests.cs


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