Skip to content

Instantly share code, notes, and snippets.

@GregRos
Last active December 14, 2015 23:39
Show Gist options
  • Save GregRos/5167357 to your computer and use it in GitHub Desktop.
Save GregRos/5167357 to your computer and use it in GitHub Desktop.
var x =
from blah in Enumerable.Range(0, 10000).AsSequential()
where blah % 2 == 1
select blah;
//By default the result of this custom list comprehension is an object called DelayedSequential<T>.
//This object is evaluated and a concrete collection is returned via an implicit conversion.
Sequential<int> s = x;
//Alternatively, we can write
Sequential<int> y =
from blah in Enumerable.Range(0, 1000).AsSequential()
select blah;
//In which case the conversion occurs right after the query is completed.
//More complex stuff:
var z =
from blah in Enumerable.Range(0, 100).AsSequential()
from blah2 in Enumerable.Range(0, blah)
select blah2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment