Click here to Skip to main content
15,910,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what is the difference between object and constructor
Posted
Comments
[no name] 23-Jun-12 9:30am    
Please stop posting questions like this. You will not be able to get a sufficient understanding of programming this way. If you want to learn about the subject then get a book or take a class. You will learn much better and it will stop wasting your time and our time.

See the below code:
C#
Public class Employee
{
   int Id;
   string Name;

   public Employee(int Id)
   {
     this.Id = Id;
   }
}

Employee emp = new Employee(1);


In the below code emp is the object, it holds instance of the employee.

C#
public Employee(int Id)


The above line is the constructor, which is used to initialize object while creation.
 
Share this answer
 
v2
Comments
André Kraak 23-Jun-12 6:58am    
Edited solution:
Added pre tags
wings_ 27-Sep-12 0:39am    
great aricle sir
You can't compare these two things by this way.

Actually Constructor initializes the Objects
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900