appendix-a

Appendix A. Notes on C#

 

In this appendix we will

  • Explain some features of C# used in this book that might be unfamiliar to some readers
  • Give examples of similar features in other languages

This appendix gives a quick overview of some of the features that are used in this book but might not be immediately familiar to the reader, either because they are relatively new C# features, or because after decades of evolution, C# is no longer as familiar to Java and C++ programmers as it once was.

A.1 Value and reference types

C# broadly groups most types into two categories: value types and reference types. A variable of value type contains a value of that type. A variable of reference type contains a reference to an object of that type, or a null reference. Built-in types such as byte, char, int, double, and decimal are value types; object, string, all array types, all interface types, and so on, are reference types. C# has pointer types but I do not use them in this book.

User-defined value types are declared with the struct keyword; user-defined reference types are declared with the class keyword. In this book I sometimes use structs as wrappers around other value types or reference types for performance or clarity.

A.2 Generic types are fully instantiated at runtime

A.3 Nullable types

A.4 Sugars

A.5 Extension methods

A.6 Sequences, iterators and lambdas