The back cover of Inside C# proclaims it as “a detailed look at the internal architecture of the groundbreaking new C# language….” Whether C# is truly groundbreaking remains a subject of debate, but Inside C# does deliver some of the goods when it comes to C#’s internals. The only problem is, the book can’t seem to decide if it wants to be a language tutorial or an architecture reference.
The author, Tom Archer, is a longtime C++ programmer who has work credits with IBM WorldBook Encyclopedia and Peachtree Office Accounting under his belt. Aside from Inside C#, Archer has authored or coauthored four books on subjects ranging from Visual C++ to Web development. His background comes through in the text, as he often goes to great trouble to illustrate the differences between the C++ and C# implementations of language features like variable lifetimes, object references, member access, and inheritance. If you are coming from C++, you’ll certainly appreciate the extra care devoted to you, but Java programmers will likely become bored quickly with the frequent divergences.
In the beginning, all is well. The book begins with a 21-page introduction and refresher of object-oriented programming and then moves on to an overview of Microsoft .NET and the .NET framework. Here, Archer describes the Common Language Runtime (CLR), Common Language Specification (CLS), managed vs. unmanaged code, and .NET’s distribution model, and he introduces Microsoft Intermediate Language (MSIL).
MSIL is the lowest-common-denominator language for .NET, generated by all CLS-compliant compilers. The CLR compiles the generated MSIL into native code either at runtime or install time (depending on the distribution method used). Throughout the book, Archer refers the reader to MSIL listings, which are more than a little reminiscent of assembler, to illustrate what’s going on at the lowest-common-denominator level whenever he needs to make a subtle point about a language feature.
By Chapter 3, the reader is writing code, in the form of the traditional “Hello, World” program we have all grown to know and love. Thankfully, Archer doesn’t devote a lot of time to this, showing us the C# source and the resulting MSIL code and then quickly moving on to discuss namespaces and provide a suggested set of programming guidelines for C# applications.
Beginning with Chapter 4, which offers an introduction to the type system, the book seems to want to turn into a language reference. Chapter 5 introduces C# classes, constructors, and garbage collection. Chapter 6 covers methods and their parameters, as well as overloading and overriding syntax. In Chapter 7, the reader becomes familiar with properties, arrays, and object indexers—constructs that allow an object to be referenced like an array. Attributes, a neat way of including metadata about a code element in the code itself, are introduced in Chapter 8, and interfaces are described in Chapter 9.
Archer does pause repeatedly along the way to discuss the how and why of certain features in C#, but unfortunately, all too often, the discussion stops at something along the lines of “the C# team wanted to make your life easier, so they chose to do it this way.”
Back to basics, in a strange place
In Chapters 10 and 11, which begin Part 3, “Writing Code,” Inside C# introduces basic syntax and flow control. Expressions, operators, order of evaluation, switch, if, do/while… they are all discussed, once again with an emphasis on their differences from C++. Now, is it just me, or does it strike anyone else as a little odd to have an introduction to the language basics in the 10th and 11th chapters of a reference book?
In the next few chapters, you’ll also learn about exception handling, operator overloading, user-defined conversions, and finally event handling. Archer devotes some time to each of these topics, providing guidelines for, and source code examples of, the effective use of each language feature.
The final section, “Advanced C#,” sees the book get back on track. It includes four chapters covering multithreaded programming and synchronization, reflections, using unmanaged code, and working with .NET’s code packages (assemblies). These chapters are all reasonably in-depth looks at complicated topics, if a little short. However, liberal use of sample C# and MSIL code makes them understandable.
The CD bound into the book includes the text in searchable e-book format, with copies of all the example code used in the text.
A little disappointing
In the end, what you get out of Inside C# mostly depends on where you’ve been. Non-Java people will find it to be a useful introduction to the language. Java programmers, on the other hand, would likely be better served by simply skimming through the language specification in the MSDN library. Don’t get me wrong; it’s not that this is a bad book—mislabeled would be a more accurate complaint. For better than half of its contents, Inside C# just doesn’t seem to deliver on its promise to provide “a detailed look at the internal architecture“ of C#.
Are you looking for C# info?
Are you trying to learn C# or just get some more information on it? What resources would you recommend? Send us an e-mail with your thoughts and suggestions or post a comment below.