Tech Tock

Time is of the essence.

Linq.Debug.Print

Here’s a great explanation of System.Interactive.

I really liked this part about being able to do debug.print within a multipart Linq Statement:

var res = GetRandomNumbers(100)
.Take(10) .Do(x => Console.WriteLine(“Source -> {0}”, x))
.Where(x => x % 2 == 0)
.Do(x => Console.WriteLine(“Where -> {0}”, x))
.OrderBy(x => x)
.Do(x => Console.WriteLine(“OrderBy -> {0}”, x))
.Select(x => x + 1)
.Do(x => Console.WriteLine(“Select -> {0}”, x));

The below shows what’s triggered by the call to Run:

Source  -> 96
Where   -> 96
Source  -> 25
Source  -> 8
Where   -> 8
Source  -> 79
Source  -> 25
Source  -> 3
Source  -> 36
Where   -> 36
Source  -> 51
Source  -> 53
Source  -> 81
OrderBy -> 8
Select  -> 9
9
OrderBy -> 36
Select  -> 37
37
OrderBy -> 96
Select  -> 97
97

Advertisements

January 12, 2010 - Posted by | Uncategorized | , ,

1 Comment »

  1. very enjoyable read i have learnt a lot from this post

    Comment by Rodolfo Zeigler | March 14, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: