This article will discuss about objects in programming. Watch our 500 videos on Azure, WCF, WPF, LINQ, Design Patterns, WWF, Silverlight, UML @ http://www.questpond.com
What is an object?
- An object is a software bundle of variables and related methods.
- Objects are related to real life scenario
- Class is the general thing and object is the specialization of general thing
- Objects are instance of classes.
- Declaration of an Object in C#.NET
- ClassName objectName=new ClassName();
- E.g.: Person objPerson= new Person();
An object is characterized by concepts like:
1. What is an Attribute?
- Attributes define the characteristics of a class.
- The set of values of an attribute of a particular object is called its state.
- In Class Program attribute can be a string or it can be a integer
Example of Attribute:
2. What is a Behavior?
- Every object has behavior
- In C#, behaviors of objects are written in methods.
- If a behavior of an object needs to be performed, then the corresponding method is called.
Example of Behavior:
3. What is an Identity?
- Each time an object is created the object identity is been defined.
- This identity is usually created using an identifier which is derived from the type of item
Example of Identity:
You can find source code at the bottom of this article.