Tonight I finished reading...

C# in Depth: What you need to master C# 2 and 3
by Jon Skeet

Read more about this book...

This was an amazing book, and definitely offers a great in depth look at the C# language. Most importantly it answered a lot of my questions about elements introduced in C# 3.0, and taught me things I didn't know about C# 1.0. If you're looking for information on the following items, then this book is definitely for you.

Thanks JP for recommending this book!

Here are a few gems that I picked from this book.

Delegates

"You rarely see an explicit call to Delegate.Combine in C# code - usually the + and += operators are used."

1 var x = new EventHandler(delegate { });
2   var y = new EventHandler(delegate { });
3   x += y;
4   x = x + y;// same as above
5   x = (EventHandler) Delegate.Combine(x, y);// same as above

Static vs Dynamic Typing

"C# is statically typed: each variable is of a particular type, and that type is known at compile time. The alternate to static typing is dynamic typing, which can take a variety of guises. "

Explicit vs. Implicit Typing

"The distinction between explicit typing and implicit typing is only relevant in statically typed languages. With explicitly typing, the type of every variable must be explicitly stated in the declaration. Implicit typing allows the compiler to infer the type of the variable based on its use."

Covariant vs. Incovariant

1 object[] stuff = new string[]{"blah"}; // valid and is an example of covariance
2   List<object> more_stuff = new List<string>();// invalid and is an example of incovariance

Fluent Interfaces

Jon, the author, mentions a blog post by Anders Noras on Planning a fluent interface

Here's an example of a fluent interface for building menu's that I've been playing with.

1 CreateA.MenuItem()
2     .Named("&amp;Close")
3     .BelongsTo(MenuGroups.File)
4     .CanBeClickedWhen(m => task.IsThereAProtocolSelected())
5     .WhenClickedExecute(closeCommand)
6     .Build();

Readability

"When it comes to getting the broad sweep of code, what is required is 'readability of results' - I want to know what the code does, but I don't care how it does it right now."

There's a lot of information on IQueryables, Expression Trees, and other goodness in this book. This is a great book and definitely worth reading, especially if you're as interested in the C# language as I am.

comments powered by Disqus