Skip to main content

Classes and Objects

  • Chapter
Introducing Visual C# 2010
  • 1710 Accesses

Abstract

In this chapter, we have examined two of the fundamental building blocks of C# programming: classes and objects. We have seen how classes act as blueprints for the creation of objects and how those objects can be modified to reflect changes in state and used to perform actions and calculations.

We also covered the three pillars of object orientation as they apply to classes and objects and learned how inheritance, encapsulation, and polymorphism can be used to create classes with less code that are easy to modify, extend, and maintain.

We saw how object reference can be converted from one type to another using implicit and explicit casting and how this differs from the boxing and unboxing approach used for value types. In looking at how C# supports casting, we saw how the is and as operators can be used to avoid problems when downcasting to a more specialized type.

Finally, we looked at the modifiers you can apply to classes to change their behavior, ranging from classes that cannot be derived to those that force derived classes to provide implementations of methods and other members before they can be used to instantiate objects. In the coming chapters, we’ll look at the different types of members that a class (and therefore an object) can contain.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2010 Adam Freeman

About this chapter

Cite this chapter

Freeman, A. (2010). Classes and Objects. In: Introducing Visual C# 2010. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-3172-1_6

Download citation

Publish with us

Policies and ethics