What Will You Learn?


The book takes a top-down look at what exactly makes up a class in .NET. We begin by describing what a type is, and how classes relate to the .NET type framework. Then we examine what makes up types: type members. We devote the majority of the book to looking at the different mechanisms C# provides for defining type members (methods, constructors, properties, operators, and events), and finally examine how types go together to make up assemblies.

Chapter by chapter, here's what to expect:

  • Chapter 1 – Defining Types

    This chapter explains what exactly a type is, what role types play in .NET, and what kinds of types exist. We also examine the different types we can declare in C# and how they map to .NET types.

  • Chapter 2 – Type Members

    In the second chapter, we examine type members: what they are, how we can define them, and how we can modify them using C# keywords. We also examine the type members inherited by every type from the .NET root class, System.Object.

  • Chapter 3 – Methods

    Methods are the workhorse of .NET applications; they contain all our program logic. This chapter examines the behavior common to all methods, and how simple methods are defined in C#. We look at how parameters are passed to methods, and how methods return values, or throw exceptions, to communicate back to the code that called them.

  • Chapter 4 – Properties and Operators

    Properties (both scalar and indexed) are a mechanism allowing us to create specialized methods for accessing data belonging to our type. Operators are specialized methods that allow consumers of our types to combine them using convenient operator-based syntax. This chapter examines how properties are implemented, how indexed properties work, and the creation and use of operators.

  • Chapter 5 – Constructors and the Object Lifecycle

    Constructors are special methods that are called to initialize new instances of a type. In this chapter, we see how these special methods are coded, and how we can use them to control what code can create instances of a type. We'll also examine object cloning, conversion operators, and some common coding techniques for controlling the creation of instances of our classes.

  • Chapter 6 – Events and Delegates

    The most complex type member in C# is the Event, and the most complex of C#'s types is the delegate. Events are based on delegates, and the combination of the two can be quite daunting for programmers. This chapter explains how delegates work, and then how .NET provides its event infrastructure through delegate fields and specialized methods.

  • Chapter 7 – Inheritance and Polymorphism

    A type is more than the sum of its members; it also has all the members it inherits from its superclass as well. This chapter explains how .NET type inheritance works, when members are and aren't inherited, and how we can control and exploit it using C#. We also look at the role and use of interfaces and abstract classes.

  • Chapter 8 – Code Organization and Metadata

    When we code a class in C#, we have to make some decisions about where exactly to put it, both logically within a namespace structure, and physically, within a source file, and ultimately, within a .NET assembly. This chapter discusses these issues. We also see how to add data to our classes that may be of use to other code that makes use of them, using .NET metadata, and how to document our classes to provide information for other programmers about how they are used.




C# Class Design Handbook(c) Coding Effective Classes
C# Class Design Handbook: Coding Effective Classes
ISBN: 1590592573
EAN: 2147483647
Year: N/A
Pages: 90

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net