-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a98de8e
commit 85272c5
Showing
3 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.Defer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
uid: SuperLinq.SuperEnumerable.Defer``1(System.Func{System.Collections.Generic.IEnumerable{``0}}) | ||
example: [*content] | ||
--- | ||
The following code example demonstrates how to defer the execution of a method that returns an enumerable using `Defer`. | ||
[!code-csharp[](SuperLinq/Defer/Defer.linq#L6-)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var count = 3; | ||
|
||
// Use a function to create a sequence at execution time | ||
var result = SuperEnumerable | ||
.Defer(() => Enumerable.Range(1, count)); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// changing count changes the length of the sequence | ||
// returned by the function given to Defer | ||
count = 5; | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [1, 2, 3] | ||
// [1, 2, 3, 4, 5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters