Summary


In this chapter, you've seen how you can define classes and interfaces in C#, which has put the theory from the last chapter into a more concrete form. You've seen the C# syntax required for basic declarations as well as the accessibility keywords you can use, the way in which you can inherit from interfaces and other classes, how to define abstract and sealed classes to control this inheritance, and how to define constructors and destructors.

You took a look at System.Object, which is the root base class of any class that you define. This class supplies several methods, some of which are virtual, so you can override their implementation. This class also allows you to treat any object instance as an instance of this type, enabling polymorphism with any object.

You also took a look at some of the tools supplied by VS for OOP development, including the Class View window, the Object Browser window, and a quick way to add new classes to a project. As an extension of this multifile concept, you also saw how you can create assemblies that you can't execute, but that contain class definitions that you can use in other projects.

Next you drilled down into abstract classes and interfaces, looking at the similarities and differences between them and the situations where you might use one or the other.

Finally, I resumed the discussion of reference and value types, looking at structs (the value type equivalent of objects) in slightly more detail. This led to a discussion on shallow and deep copying of objects, a subject you return to later on in the book.

In this chapter you learned:

  • How to define classes and interfaces in C#

  • The basic syntax for C# declarations

  • How inheritance works

  • How to define constructors and destructors

  • How to use System.Object

  • How to use a selection of VS tools for OOP development

  • How to use abstract classes and interfaces

  • More about reference and value types

In the next chapter you look at defining class members, such as properties and methods, which will allow you to take OOP in C# to the level required to create real applications.




Beginning Visual C# 2005
Beginning Visual C#supAND#174;/sup 2005
ISBN: B000N7ETVG
EAN: N/A
Year: 2005
Pages: 278

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