4.1. Object Creation

The cornerstone of any object-oriented programming language is the concept of an object. An object is a data structure that has methods and fields. Fields maintain the state of the object, and methods query or modify that state. Objects provide a convenient container for storing data. The number and type of lids on that container dictate the access control to the data. For example, an object that has only public methods is like an open container. Objects can get heavy (consume more memory) depending on the data they store. Objects are also used for abstracting the relationships among data.

In OOP languages such as C++, Java, and C#, objects are created using the new operator. An object is created in memory (usually the heap), ...

Get .NET for Java Developers: Migrating to C# 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.