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 ...

Get Programming Reactive Extensions and LINQ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.