Creating Abstract Classes

Say that you decided to sell the Window class commercially. In that case, note that there's no guarantee that programmers would implement their own Open methods; they might leave the default Open method in place. If you consider that inappropriate—if you want to force those programmers to implement their own Open method if they derive classes from your Window class—you can declare the Open method abstract.

You declare a method abstract simply by using the abstract keyword, as you see in ch04_05.cs, Listing 4.5. Don't give the method any body; just end the declaration of the method with a semicolon, as you see in Listing 4.5. When you give a class an abstract method, that method must be overridden in any derived classes, ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.