Home > Articles > Software Development & Management > Object Technology

  • Print
  • + Share This
This chapter is from the book

In Brief

This chapter covered the essentials of C# OOP, starting with creating classes and objects. We saw that access modifiers let you restrict access to the members of classes and structs, encapsulating your data and methods as needed. Here's an overview of the topics we covered:

  • We can add fields, methods, and properties to classes, and we can initialize fields with initializers. We can use the this keyword in methods, and create not only standard properties, but also read-only and static properties. And we can create constructors and copy constructors to initialize the data in objects.

  • Static members are declared with the static keyword, and are associated with the class itself, not with objects created from that class. Static fields can store data for the class, and static methods and properties can be called without first instantiating an object.

  • Method overloading is implemented by providing alternative definitions of the same method with different signatures. Operator overloading uses the operator keyword to let you specify which operator to overload.

  • When we overloaded the == operator, C# will issue a warning unless we also override the Object.Equals and Object.GetHashCode methods.

  • + Share This
  • 🔖 Save To Your Account