Chapter 3: Object-Oriented C

 
Chapter 3 - Object-Oriented C#
bySimon Robinsonet al.
Wrox Press 2002
  

Overview

In this chapter, we will introduce the C# object-oriented features. In particular, we will cover:

  • The C# syntax for inheritance , virtual functions and related features.

  • Method Overloading - C# allows you to define different versions of a method in a class, and the compiler will automatically select the most appropriate one based on the parameters supplied.

  • Construction and Destruction - it is possible to specify how objects should be initialized as well as any action that needs to be automatically taken when they are destroyed .

  • Structs - on occasions you need something that has the many of the features of a class without all of the overhead involved in creating a class instance. Structs are value types that provide this facility.

  • Operator Overloading - we will examine how to define operators for your classes.

  • Indexers - indexers allow a class to be treated syntactically as if it is an array, and can simplify the use of classes that contain sets of objects.

  • Interfaces - C# supports interface inheritance as well as implementation inheritance. We will examine this feature.

We will assume that you are already familiar with the principles of object-oriented programming, such as inheritance and polymorphism, so that we can focus largely on how C# implements OOP. If you are not familiar these with object-oriented principles then you should read Appendix A, which introduces object-oriented concepts, before attempting this chapter.

On the other hand, we will introduce and explain those concepts that are not necessarily supported by most object-oriented languages. For example, although object constructors are a widely used concept, static constructors are something new to C#, so we will explain in more detail how they work.

  


Professional C#. 2nd Edition
Performance Consulting: A Practical Guide for HR and Learning Professionals
ISBN: 1576754359
EAN: 2147483647
Year: 2002
Pages: 244

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