O'Reilly logo

Programming Reactive Extensions and LINQ by Paul Betts, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C# and .NET Fundamentals

Now that you have both tools working, let's take this small program apart line by line and examine the constructs it uses. In the next section, we'll review some features of C# and .NET, whose mastery is fundamental to Rx and LINQ.

Var

Let's consider the program from the beginning. The first line could have been written as follows:

List<int> list = new List<int>( ) { 1, 2, 3, 5, 7, 11, 13 };

The results would have been identical. The advantages of the var keyword are that you avoid redundancy and that it is a bit terser. Further, there are times when you, as the programmer, may not know the type and letting the compiler infer the type (as is done with var) can be a tremendous time-saver—why look up the type when the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required