FREE BOOK

Chapter 5: Advanced C# Class Construction Techniques

Posted by Apress Free Book | C# Language January 13, 2009
This chapter rounds out your introduction to the core aspects of the C# language by examining a number of advanced (but extremely useful) syntactic constructs. To begin, you learn how to construct and use an indexer method.

Summary

The purpose of this chapter was to round out your understanding of the key features of the C# language. You are now well-equipped to build sophisticated object models that function well within the .NET universe. The chapter began by examining how to build a custom indexer method, which allows the object user to access discrete sub-items using array-like notation. Next, the chapter examined how the C# language enables you to overload various operators in order to let your custom types behave a bit more intuitively  to the object users of the world.

You have also seen three ways in which multiple objects can partake in a bidirectional conversation. The first two approaches (delegates and events) are official, well-supported constructs in the .NET universe. The third approach (event interfaces) is more of a design pattern than a language protocol; however, it does allow two entities to communicate in a type-safe manner.

I wrapped up this chapter by examining how to comment your types using XML comment tags, and you learned how the Visual Studio.NET IDE can make use of these tags to generate online documentation for your current project. Using these techniques, you enable your peers to fully understand the fruit of your .NET labors.

Total Pages : 11 7891011

comments