Object definition with example in C#.Net

OBJECT

Definition: 

A class is like a blue print, which specifies what the type can do. An object is nothing but a block of memory, that has been configured and allocated according to the blue print. 


  • One program can create any number of objects. 
  • We can call objects as instances, because objects will store in an array or named variable or collection. 
  • A program can have multiple objects and interacting dynamically. 

Example:

Here we are creating instance of A class in the B class. After that we are accessing A class properties after creating an object of A Class. 

class A
{
public int i=0;
public string strName=string.empty;
}

Class B
{
A obj=new A();
obj.i=30;
obj.strName="ranga";
}

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar