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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights 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
DOI: https://doi.org/10.1007/978-1-4302-3172-1_6
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4302-3171-4
Online ISBN: 978-1-4302-3172-1
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)