Part 5: Convenience features

Introduction

Compared to Java, C# has several features that make things more convenient for the developer. Instead of accessor (getter) and mutator (setter) methods, we have C# properties. Besides being a cleaner and more elegant way of implementing getter and setter methods, public properties act and feel exactly like public fields to external parties - without the associated 'it-is-poor-programming-practice-to-make-your-fields-public' stigma.

C# also comes with indexes, operator overloading (a feature of C++ which Java dumped), and user-defined casting operations. These features are not really essential for an OO language and their functionality can be implemented using common methods. Nevertheless, additional ...

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.