Chapter 10. Designing and Writing Custom Classes

In Chapter 9 I initiated a discussion about designing your own classes. I ended that chapter by designing and writing a simple class named clsDates that added two methods: getLeapYear() and getEaster(). This chapter continues the theme of class design, but gets into additional details about writing classes. In this chapter you will learn about:

  • Constructor details

  • Method overloading

  • Cohesion

  • Coupling

  • Property methods

  • Getters and setters

  • Changing the state of an object

  • Sensing an error in a class method

When you finish this chapter, you will have a solid foundation upon which to start writing your own classes. With a little effort, I think you'll find that it is both worthwhile and kind of fun.

Get Beginning C# 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.