C# Corner
Tech
News
Videos
Forums
Trainings
Books
Live
More
Interviews
Events
Jobs
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Difference Between Class And Structure
WhatsApp
Prerna Kalra
8y
362.2
k
0
8
25
Blog
This blog defines the difference between Class and Structure.
Class
Class is a reference type and its object is created on the heap memory.
Class can inherit the another class.
Class can have the all types of constructor and destructor.
The member variable of class can be initialized directly.
class object can not be created without using the new keyword, it means we have to use it.
Demo obj=new Demo();
Structure
Structure is a value type that is why its object is created on the stack memory.
Structure does not support the inheritance.
Structure can only have the parametrized constructor. it means a structure can not have the non-parametrized constructor,default constructor and destructor also.
The member variable of structure can not be initialized directly.
Structure object can be created without using the new keyword.(optional)
Demo obj;
People also reading
Membership not found