Tag Archives: OOPS

Back to basics !!! What is an Object ???

Objects are programming constructs that have identity, behavior and data.

Object data is contained in the fields, properties, and events of the object. The data stored within the object at any given moment of time, in oops fields, constants, properties i.e. attributes define the state of an object. The set of values of an attribute of a particular object is called its state.

Object behavior – What an object can do. Object behaviors are defined by the methods and interfaces of the object. In OOP methods define the functions which define the actions that object can perform.

Objects identity — Means every object is unique and can be differentiated from other objects, each time object is getting created/instantiated a separate object identity is defined. Two objects with the same set of data are not necessarily the same object.

Example – In General,
Let’s say we have a Car
Then Color, Wheels, Breaks, Gear, Seats, Lights, License Plate Steering Wheel etc are the attributes/data
We can have cars functions/behaviors like Start, Stop, Accelerate, Break, and Steer etc.
And we have Car identity which is combination of different factors like make, model, chassis number etc to uniquely identify car

In Terms of C#
Objects in C# are defined through classes and structs — these form the single blueprint from which all objects of that type operate.

As per MSDN
A Class or Struct definition is like a blueprint that specifies what the type can do. An object is basically a block of memory that has been allocated and configured according to the blueprint. A program may create many objects of the same class. Objects are also called instances, and they can be stored in either a named variable or in an array or collection. Client code is the code that uses these variables to call the methods and access the public properties of the object. In an object-oriented language such as C#, a typical program consists of multiple objects interacting dynamically.

Objects have the following properties:
 Everything you use in C# is an object, including Windows Forms and controls.
 Objects are instantiated; that is, they are created from templates defined by classes and structs.
 Objects use Properties (C# Programming Guide) to obtain and change the information they contain.
 Objects often have methods and events that allow them to perform actions.
 Visual Studio provides tools for manipulating objects: the Properties Window allows you to change the attributes of objects such as Windows Forms. The Object Browser allows you to examine the contents of an object.
 All C# objects inherit from the Object.