实例介绍
MoreLINQ是一个针对LINQ to Objects的增强库,它补充了一些LINQ中缺失的有用特性。通过引入额外的方法,MoreLINQ项目保持了LINQ的设计精神,同时为.NET开发者提供了更多的便利和灵活性。
使用方法
使用MoreLINQ非常简单,只需导入MoreLinq命名空间,即可使所有扩展方法立即可用。这些方法主要扩展了IEnumerable<T>的实例。在极少数情况下,如果你已经使用了其他也通过相同名称和签名扩展了相同类型的库,可能会导致冲突。从MoreLINQ 3.0版本开始,你可以通过C# 6的静态导入功能,仅导入需要的扩展方法来减少潜在的冲突。
除了扩展方法,MoreLINQ还提供了一些常规的静态方法,用于生成(而不是操作)序列,如Unfold、Random、Sequence等。如果你希望在静态导入其他扩展方法的同时使用这些方法,可以通过别名的方式来实现。
主要操作
MoreLINQ提供了众多实用的方法,例如:
- Batch:将源序列分批处理。
- Concat:连接两个序列。
- DistinctBy:根据指定的键选择器返回序列中的不重复元素。
- MaxBy和MinBy:根据给定的投影返回序列中的最大值或最小值元素。
- Pad和PadStart:如果序列长度小于给定宽度,则用默认值填充序列。
- Permutations:生成序列的所有排列。
- Shuffle:返回原始序列中元素的随机排序。
通过这些方法,开发者可以更加灵活地处理和操作序列,提高.NET应用开发的效率和质量。
【实例截图】
【核心代码】
文件清单
└── MoreLINQ-60390e8d9825b86c68982ebae3cd30c1549cdec3
├── COPYING.txt
├── Directory.Build.props
├── MoreLinq
│ ├── Acquire.cs
│ ├── Aggregate.g.cs
│ ├── Aggregate.g.tt
│ ├── AggregateRight.cs
│ ├── Append.cs
│ ├── AssemblyInfo.cs
│ ├── Assert.cs
│ ├── AssertCount.cs
│ ├── Assume.cs
│ ├── Backsert.cs
│ ├── Batch.cs
│ ├── Cartesian.g.cs
│ ├── Cartesian.g.tt
│ ├── Choose.cs
│ ├── CollectionLike.cs
│ ├── Collections
│ │ └── Dictionary.cs
│ ├── CompatibilitySuppressions.xml
│ ├── Consume.cs
│ ├── CountBy.cs
│ ├── CountDown.cs
│ ├── CountMethods.cs
│ ├── Debug.cs
│ ├── Delegating.cs
│ ├── Disposable.cs
│ ├── DistinctBy.cs
│ ├── Duplicates.cs
│ ├── EndsWith.cs
│ ├── EquiZip.cs
│ ├── Evaluate.cs
│ ├── ExceptBy.cs
│ ├── Exclude.cs
│ ├── Experimental
│ │ ├── Aggregate.cs
│ │ ├── Async
│ │ │ ├── ExperimentalEnumerable.cs
│ │ │ └── Merge.cs
│ │ ├── Await.cs
│ │ ├── Batch.cs
│ │ ├── CurrentBuffer.cs
│ │ ├── ExperimentalEnumerable.cs
│ │ ├── Memoize.cs
│ │ └── TrySingle.cs
│ ├── Extensions.ToDataTable.g.cs
│ ├── Extensions.g.cs
│ ├── ExtremaMembers.cs
│ ├── FallbackIfEmpty.cs
│ ├── FillBackward.cs
│ ├── FillForward.cs
│ ├── Flatten.cs
│ ├── Fold.cs
│ ├── Fold.g.cs
│ ├── Fold.g.tt
│ ├── ForEach.cs
│ ├── From.cs
│ ├── FullGroupJoin.cs
│ ├── FullJoin.cs
│ ├── Generate.cs
│ ├── GenerateByIndex.cs
│ ├── GlobalRandom.cs
│ ├── GroupAdjacent.cs
│ ├── IdFn.cs
│ ├── Index.cs
│ ├── IndexBy.cs
│ ├── Insert.cs
│ ├── Interleave.cs
│ ├── Lag.cs
│ ├── Lead.cs
│ ├── LeftJoin.cs
│ ├── ListLike.cs
│ ├── Lookup.cs
│ ├── MaxBy.cs
│ ├── Maxima.cs
│ ├── MinBy.cs
│ ├── Minima.cs
│ ├── MoreEnumerable.cs
│ ├── MoreLinq.csproj
│ ├── Move.cs
│ ├── OrderBy.cs
│ ├── OrderByDirection.cs
│ ├── OrderedMerge.cs
│ ├── Pad.cs
│ ├── PadStart.cs
│ ├── Pairwise.cs
│ ├── PartialSort.cs
│ ├── Partition.cs
│ ├── PendNode.cs
│ ├── Permutations.cs
│ ├── Pipe.cs
│ ├── PreScan.cs
│ ├── Prepend.cs
│ ├── PublicAPI
│ │ ├── net6.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ ├── net8.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ ├── netstandard2.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ └── netstandard2.1
│ │ ├── PublicAPI.Shipped.txt
│ │ └── PublicAPI.Unshipped.txt
│ ├── Random.cs
│ ├── RandomSubset.cs
│ ├── Rank.cs
│ ├── Reactive
│ │ ├── Observable.cs
│ │ └── Subject.cs
│ ├── Repeat.cs
│ ├── Return.cs
│ ├── ReverseComparer.cs
│ ├── RightJoin.cs
│ ├── RunLengthEncode.cs
│ ├── Scan.cs
│ ├── ScanBy.cs
│ ├── ScanRight.cs
│ ├── Segment.cs
│ ├── Sequence.cs
│ ├── SequenceException.cs
│ ├── Shuffle.cs
│ ├── SkipLast.cs
│ ├── SkipUntil.cs
│ ├── Slice.cs
│ ├── SortedMerge.cs
│ ├── Split.cs
│ ├── StartsWith.cs
│ ├── Subsets.cs
│ ├── TagFirstLast.cs
│ ├── TakeEvery.cs
│ ├── TakeLast.cs
│ ├── TakeUntil.cs
│ ├── ToArrayByIndex.cs
│ ├── ToDataTable.cs
│ ├── ToDelimitedString.cs
│ ├── ToDelimitedString.g.cs
│ ├── ToDelimitedString.g.tt
│ ├── ToDictionary.cs
│ ├── ToHashSet.cs
│ ├── ToLookup.cs
│ ├── Trace.cs
│ ├── Transpose.cs
│ ├── Traverse.cs
│ ├── Unfold.cs
│ ├── UnreachableException.cs
│ ├── Window.cs
│ ├── WindowLeft.cs
│ ├── WindowRight.cs
│ ├── ZipImpl.cs
│ ├── ZipLongest.cs
│ ├── ZipShortest.cs
│ ├── key.snk
│ ├── tt.cmd
│ └── tt.sh
├── MoreLinq.Test
│ ├── AcquireTest.cs
│ ├── AggregateRightTest.cs
│ ├── AggregateTest.cs
│ ├── AppendTest.cs
│ ├── AssertCountTest.cs
│ ├── AssertTest.cs
│ ├── Async
│ │ ├── AsyncEnumerable.cs
│ │ ├── MergeTest.cs
│ │ ├── TestExtensions.cs
│ │ ├── TestingAsyncSequence.cs
│ │ └── WatchableEnumerator.cs
│ ├── AtLeastTest.cs
│ ├── AtMostTest.cs
│ ├── BacksertTest.cs
│ ├── BatchTest.cs
│ ├── BreakingAction.cs
│ ├── BreakingCollection.cs
│ ├── BreakingFunc.cs
│ ├── BreakingList.cs
│ ├── BreakingReadOnlyCollection.cs
│ ├── BreakingReadOnlyList.cs
│ ├── BreakingSequence.cs
│ ├── CartesianTest.cs
│ ├── ChooseTest.cs
│ ├── Combinatorics.cs
│ ├── Comparable.cs
│ ├── CompareCountTest.cs
│ ├── ConsumeTest.cs
│ ├── CountBetweenTest.cs
│ ├── CountByTest.cs
│ ├── CountDownTest.cs
│ ├── CurrentThreadCultureScope.cs
│ ├── DistinctByTest.cs
│ ├── DuplicatesTest.cs
│ ├── EndsWithTest.cs
│ ├── Enumerable.cs
│ ├── EqualityComparer.cs
│ ├── EquiZipTest.cs
│ ├── EvaluateTest.cs
│ ├── ExactlyTest.cs
│ ├── ExceptByTest.cs
│ ├── ExcludeTest.cs
│ ├── Extensions.cs
│ ├── FallbackIfEmptyTest.cs
│ ├── FillBackwardTest.cs
│ ├── FillForwardTest.cs
│ ├── FlattenTest.cs
│ ├── FoldTest.cs
│ ├── ForEachTest.cs
│ ├── FromTest.cs
│ ├── FullGroupJoinTest.cs
│ ├── FullJoinTest.cs
│ ├── FuncModule.cs
│ ├── GenerateTest.cs
│ ├── GroupAdjacentTest.cs
│ ├── IndexByTest.cs
│ ├── IndexTest.cs
│ ├── InsertTest.cs
│ ├── InterleaveTest.cs
│ ├── KeyValuePair.cs
│ ├── LagTest.cs
│ ├── LeadTest.cs
│ ├── LeftJoinTest.cs
│ ├── Make.cs
│ ├── MaximaTest.cs
│ ├── MemoizeTest.cs
│ ├── MinimaTest.cs
│ ├── MoreLinq.Test.csproj
│ ├── MoveTest.cs
│ ├── NullArgumentTest.cs
│ ├── OrderByTest.cs
│ ├── OrderedMergeTest.cs
│ ├── PadStartTest.cs
│ ├── PadTest.cs
│ ├── PairwiseTest.cs
│ ├── PartialSortByTest.cs
│ ├── PartialSortTest.cs
│ ├── PartitionTest.cs
│ ├── PermutationsTest.cs
│ ├── PipeTest.cs
│ ├── PreScanTest.cs
│ ├── PrependTest.cs
│ ├── Program.cs
│ ├── RandomSubsetTest.cs
│ ├── RandomTest.cs
│ ├── RankTest.cs
│ ├── ReadOnlyCollection.cs
│ ├── RepeatTest.cs
│ ├── ReturnTest.cs
│ ├── RightJoinTest.cs
│ ├── RunLengthEncodeTest.cs
│ ├── SampleData.cs
│ ├── ScanByTest.cs
│ ├── ScanRightTest.cs
│ ├── ScanTest.cs
│ ├── Scope.cs
│ ├── SegmentTest.cs
│ ├── SequenceReader.cs
│ ├── SequenceTest.cs
│ ├── ShuffleTest.cs
│ ├── SkipLastTest.cs
│ ├── SkipUntilTest.cs
│ ├── SliceTest.cs
│ ├── SortedMergeTest.cs
│ ├── SplitTest.cs
│ ├── StartsWithTest.cs
│ ├── SubjectTest.cs
│ ├── SubsetTest.cs
│ ├── TagFirstLastTest.cs
│ ├── TakeEveryTest.cs
│ ├── TakeLastTest.cs
│ ├── TakeUntilTest.cs
│ ├── TestException.cs
│ ├── TestExtensions.cs
│ ├── TestingSequence.cs
│ ├── Throws.cs
│ ├── ToArrayByIndexTest.cs
│ ├── ToDataTableTest.cs
│ ├── ToDelimitedStringTest.cs
│ ├── ToDictionaryTest.cs
│ ├── ToLookupTest.cs
│ ├── TraceTest.cs
│ ├── TransposeTest.cs
│ ├── TraverseTest.cs
│ ├── TrySingleTest.cs
│ ├── UnfoldTest.cs
│ ├── WatchableEnumerator.cs
│ ├── WindowLeftTest.cs
│ ├── WindowRightTest.cs
│ ├── WindowTest.cs
│ ├── ZipLongestTest.cs
│ ├── ZipShortestTest.cs
│ └── coverlet.runsettings
├── MoreLinq.shfbproj
├── MoreLinq.sln
├── README.md
├── appveyor.yml
├── bld
│ ├── Copyright.props
│ └── ExtensionsGenerator
│ ├── MoreLinq.ExtensionsGenerator.csproj
│ └── Program.cs
├── build.cmd
├── build.sh
├── builddocs.cmd
├── eclint.ps1
├── global.json
├── msbuild.cmd
├── pack.cmd
├── pack.sh
├── test.cmd
├── test.sh
└── tools
├── dotnet-install.ps1
├── dotnet-install.sh
├── mark-shipped.cmd
└── mark-shipped.ps1
16 directories, 302 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论