I read through this book in preparation for my resolution of writing applications for Windows Phone 7 devices. This book is a great starting point for anyone looking to get involved with .NET or Silverlight programming. .NET BOOK ZERO started out as an introduction chapter to .NET, trying to cover some of the key differences between C++ and C#. However, it soon became obvious that this single chapter was trying to cover too much and turned into an entire book of it's own, going over the very fine details of objects and structures, to string manipulation and nullable types. You can also see a list of other books I've reviewed on the “Book Reviews” of the site.
Chapter 1: Why This Book – The latest version of this book is available for download free of charge at www.charlespetzold.com.
Chapter 2: Why .NET? - This chapter reviews the basic requirements of .NET programming including CIL and CLR. The first important difference between c++ and c# is pointed out right off the bat: no pointers!
Chapter 4: Edit, Compile, Run, Disassemble – This chapter takes a look at how namespaces are used to organize code, and the syntax used in method calls. The chapter continues to go over where namespaces fit into the compilation process.
Chapter 5: Strings and the Console – This chapter introduces the concept of static vs instance methods while reviewing the strings class.
Chapter 6: Primitive Data Types – C# supports short, int, and long integers just like C++. C# also supports boolean, character, string, floating point, double and decimal value types. Many of these data types can be used with the Math class.
Chapter 7: Operators and Expressions – Primary, unary, multiplicative, shift, relational, equality, logical, conditional, and assignment operators are discussed in this chapter.
Chapter 8: Selection and Iteration – C# supports the same selection, iteration, and flow control statements used in C++, with some restrictions. These restrictions are intended to help you avoid common coding mistakes.
Chapter 9: The Stack and the Heap – One of the most helpful chapters in this book. This chapter covers key differences between structures and classes, including what these differences mean during memory allocation, along with very clear explanations of the stack and heap.
Chapter 10: Arrays – One of the less useful chapters in the book. We go over multiple ways of initializing and filling arrays, including multi-dimensional arrays. If you have any experience with c++ you can completely skip this chapter.
Chapter 11: Methods and Fields - Most of this chapter goes over syntax of defining methods and fields. There are some notes of interest in this chapter as well. This chapter introduces c#'s alternative to using pointers by taking a deeper dive into the differences between classes and structures, and what these differences mean during the parameter passing process in c#.
Chapter 12: Exception Handling – A very short and concise review of structures of exception handling including try(), catch() and throw().
Chapter 13: Classes Structures and Objects – This chapter re-visits classes and structures, while adding some new concepts as well. The bulk of this chapter is spent on how memory is allocated on the stack and heap for different data types, and what this means for efficiency.
Chapter 14: Instance Methods – Any instance method in a class has access to the instance fields of that class. This greatly simplifies code by reducing parameters that need to be passed between functions. Instance methods can also call any other instance method, static method, or static fields of it's class. A static method has access to none of these.
Chapter 15: Constructors – This chapter goes over basic syntax for creating a constructor. All classes have a default parameter-less constructor. This constructor is deleted if a constructor is defined by the user and an error is thrown if it is used.
Chapter 16: Concepts of Equality – Every class and structure includes a method named equals. This method is defined by the System.Object class, and inherited by all other classes. This chapter defines what you are actually comparing when you use the equals operator with any class including user defined classes.
Chapter 17: Fields and Properties – In use, properties look and behave just like fields. The major difference is that properties can have code attached to them, which can be used for get and set methods. This makes using properties much cleaner to use in most cases.
Chapter 18: Inheritance – A class can only inherit from one other class, where all non-private fields, properties, and methods are inherited. However, constructors are not inherited. This chapter looks at the order of which constructors are executed from parent to child class.
Chapter 19: Virtuality – getType() and typeOf() are methods that return an object of type Type. This object can be used to determine if two objects are of the same time. Only methods and properties can be declared as virtual.
Chapter 20: Operator Overloading – Any operator can be overloaded to work with a user defined class. These operators include: +, -, !, ~, ++, –, true, false, *, /, %, ==, !=, <, >, <=, >=. This chapter includes syntax for overloading these operators, as well as example use cases.
Chapter 21: Interfaces – Classes can inherit from only one class, however they can inherit an infinite amount of interfaces. A class must include a methods of an interface it is implementing.
Chapter 22: Interoperability – This chapter demonstrates how to use platform invoke, which allows you to use Win32 API functions from your .NET programs.
Chapter 23: Dates and Times – This chapter introduces the DateTime object. Constructor parameters, tick counts, DateTime calculations and TimeSpan are explained throughout this chapter through the DateTime example project. This project is continued throughout the rest of the book.
Chapter 24: Events and Delegates – A delegate is a reference to a method. Handling events across objects is a common use of delegates. An event handler is attached to special delagates called events. These event handlers are called once an event is fired.
Chapter 25: Files and Streams – This chapter takes you through the lowest levels of file input/output with the FileStream class, reading and writing text files with the StreamReader and StreamWriter classes, and finally higher level file reading with the Environment, Path, DirectoryInfo, Directory, FileInfo, and File classes.
Chapter 26: String Theory – All strings in C# are immutable, which means that a string can not be altered once it is created. Instead you must create a new string whenever you need to adjust a string in some way. This chapter covers string manipulation and performance factors when when working with strings.
Chapter 27: Generics – Generics is the C# method for implementing the C++ template. Generics also support defining constraints that restrict the type of object that can be used with your generic.
Chapter 28: Nullable Types – Any value or structure can be made a nullable type. This is useful for defining a way for defining a value as not yet defined.
Summary: If you have a good amount of programming experience, .NET Book Zero definitely has it's share of less interesting material, some of which include data types, arrays and operators. However, I would still strongly recommend this as a starting point for anyone making the jump from C++ or C to C#. The chapters on delegates, properties, and class structures will give you a complete understanding of new concepts with extremely clear and concise explanations and examples. Chapters on stack and heap, differences between structures vs. classes, fields vs. properties, and static vs. instance were like a bonus review that cleared up some concepts that I never completely understood myself. And as a free download available at www.charlespetzold.com, the price can't be beat.
No comments:
Post a Comment