Inside C#
Tom Archer
600 pages, Paperback
ISBN: 0735616485
ISBN13:
Language: English
Publish: April 1, 2002
The Barnes & Noble Review
If technical advantage is sufficient to drive success, Microsoft’s C# will likely find a prominent place in tomorrow’s enterprise developer’s toolkit. Microsoft’s intentions for C# are to provide a strongly typed, fully object-oriented language that offers complete access to the underlying operating system’s or browser’s functionality, supports Web standards like XML, makes it easy to convert components into Web services, and in Microsoft’s words, “brings rapid development to the C++ programmer without sacrificing the power and control that have been a hallmark of C and C++.”
The early signs are promising. C# does appear to offer solutions for some of knottiest problems C++ and Java developers must find workarounds for. As an example, C# “delegates” improve upon both C++ function pointers (they’re type safe) and Java interfaces (you can invoke a method with less code, and without fooling with complex inner-class adapters).
In many discussions of C#, the core language is discussed in the context of development tools and the .NET runtime (CLR). This is unsurprising: parts of C# and .NET were designed for each other. However, serious C# developers will want a systematic guide to the language itself. And if they can find such a book, it’ll serve them for years, since the language probably won’t change much (unlike, say, Visual Studio.NET, which is likely to evolve rapidly).
Now there is such a book: Tom Archer’s Inside C#. Archer, who writes CodeGuru’s popular C#/.NET Web newsletter, offers the most systematic, authoritative C# tutorial and reference we’ve seen.
He begins with a “whirlwind tour” of object-oriented fundamentals that every C# developer must be confident with. Next, since C# is so closely related to the .NET Framework and CLR, he takes the time to explain the connections — with welcome clarity.
Then, it’s on to the language itself, starting with Hello, World. Even here, C#’s uniqueness shines through. For example, when you define a class, you must define all methods inline (unlike C++, there’s no choice, and no header files). This helps you create more mobile code: When you write a class, you wind up with a fully encapsulated “bundle of functionality” you can plunk anywhere (even in ASP pages).
Part II introduces C# class fundamentals, beginning with the C# type system. Microsoft’s developers wanted the pure object-orientation of, say, Smalltalk, but not the performance compromises that arise when you make everything an object. The solution: value types, reference types, and boxing. Says Archer, “an object is only an object when it needs to be… Boxing is how C# enables everything to appear to be an object, thereby avoiding the overhead required if everything actually were an object.” Sounds obscure? Don’t worry: Archer illustrates it with several to-the-point examples.
There’s detailed coverage of creating classes and methods, areas where “C# borrows a little from C++, a little from Java, and then adds some ingenuity to create elegant solutions to old problems.” Archer next demonstrates how to use properties, arrays, and indexers to extend the basic class/field/method structure of a class, exposing a more intuitive and natural interface to your class’s members.
Inside C# contains an excellent introduction to attributes, which let you build “self-describing” classes. These aren’t just easier to maintain: they’re capable of doing things Microsoft hasn’t even imagined yet. A comparison to C++ is instructive. Because C++ was designed before the Internet and XML explosion, it’s tough to do things like associating specific members of a C++ class with XML fields. With C#, problems like that shouldn’t arise: you can define and customize design-time and run-time information — even run-time behavior, such as whether a member can participate in a transaction.
Along the way, Inside C# teaches you how to define namespaces, debug C# code, write multithreaded applications, and use versioning to avoiding the problems that typically arise as code evolves.
Whether you’re a Visual C++ developer, a VB developer, or a web pro looking to create advanced .NET applications, C# offers powerful potential. With Inside C#, you can transform that potential into reality.
(Bill Camarda)Bill Camarda is a consultant and writer with nearly 20 years’ experience in helping technology companies deploy and market advanced software, computing, and networking products and services. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.