SawNaw.LinqExtensions.EnumerableSplit
1.0.2
See the version list below for details.
dotnet add package SawNaw.LinqExtensions.EnumerableSplit --version 1.0.2
NuGet\Install-Package SawNaw.LinqExtensions.EnumerableSplit -Version 1.0.2
<PackageReference Include="SawNaw.LinqExtensions.EnumerableSplit" Version="1.0.2" />
<PackageVersion Include="SawNaw.LinqExtensions.EnumerableSplit" Version="1.0.2" />
<PackageReference Include="SawNaw.LinqExtensions.EnumerableSplit" />
paket add SawNaw.LinqExtensions.EnumerableSplit --version 1.0.2
#r "nuget: SawNaw.LinqExtensions.EnumerableSplit, 1.0.2"
#:package SawNaw.LinqExtensions.EnumerableSplit@1.0.2
#addin nuget:?package=SawNaw.LinqExtensions.EnumerableSplit&version=1.0.2
#tool nuget:?package=SawNaw.LinqExtensions.EnumerableSplit&version=1.0.2
LINQ extension to split a collection into several.
Think of it as String.Split()
for collections.<br />
Example: Split a collection by specifying the splitters.
string[] things = { "pie", "apple", "cake", "mud-pie", "nuts", "plum", "mud-spread", "milk", "butter" };
// Literally specify the splitters.
var edibleThings = things.Split("mud-pie", "mud-spread");
edibleThings
will contain these collections: <br />
{"pie", "apple", "cake"}<br />
{"nuts", "plum"}<br />
{"milk", "butter"}<br />
Example: Split a collection by using a function to define the splitter.
string[] things = { "pie", "apple", "cake", "mud-pie", "nuts", "plum", "mud-spread", "milk", "butter" };
// Specify a function to define the splitters.
var edibleThings = things.Split(t => t.StartsWith("mud"));
edibleThings
will contain these collections: <br />
{"pie", "apple", "cake"}<br />
{"nuts", "plum"}<br />
{"milk", "butter"}
Use Cases
Any time a collection contains useful information separated by known elements.<br /><br />
For example, a text file may contain records where each record is separated by a newline. <br />
Simply read the text file, and perform a Split()
, passing in the condition for the split.
string[] fileContents = File.ReadAllLines("records.txt");
var individualRecords = fileContents.Split(x => string.IsNullOrWhiteSpace(x));
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release