Difference between Class and Structure

Amatya
Posted by in C# category on for Beginner level | Points: 250 | Views : 331 red flag

Here we will try to understand difference between class and structure, as its very important to know the concept.When developer are experienced its important to think that for specific task we should make a class or structure. So here they can know the difference and can go through class or structure as per their need.

Introduction

Here we will know the difference between class and structure, as its very important to know the concept.When developer are experienced its important to think that for specific task we should make a class or structure. So here they can know the difference and can go through class or structure as per their need. 

Background

At the time of discussion with senior when they gives task or module to work, its very important to know the difference between class and structure to put the concept and code in a proper way. So here is a small effort to know the concept

Differences are as follows:

1. A struct is a value type i.e it directly contains data. To get the size of a type we can use sizeof control method like sizeof(type). They are stored in stack whereas class is a reference type i.e. they don't contain actual data stored in a variable , they contain a reference to the variable. They are stored in heap.

2. Structure cant have destructor but class can have it.

3. Structure cant inherit from another class whereas a class can inherit. Both structure and classes can inherit from an interface.

4. When you copy a structure into another structure, a new copy of that structure get created and modification on one structure will not affect the values contained by other structure.

5. Explicit parameters constructor are not contained by structures whereas class can contain explicit parameter constructor.

6. Structure do not have destructor whereas class can have it.


Conclusion

Its a small article, but hope it will benefit developers who works in design phase or going to code for specific projects. Thanks enjoy the day with coffee.



Page copy protected against web site content infringement by Copyscape

About the Author

Amatya
Full Name: Adit Gupta
Member Level: Silver
Member Status: Member
Member Since: 5/9/2015 12:56:12 AM
Country: India
Feel free to share informations 9731764134 mail Id ' adityagupta200@gmail.com Thanks
http://www.dotnetfunda.com
Software Enginner

Login to vote for this post.

Comments or Responses

Posted by: Davidcyryl on: 5/31/2017 | Points: 25
One of the many difficulties that understudies are confronted with regards to the proposition composing procedure is that they are 'bad authors'. Since not every one of us are made to be artistic of scholastic masters who can think of a respectable paper in a matter of days, you can compensate for it in exertion, association and putting in a considerable measure of time to composing your postulation. http://www.affordable-dissertation.co.uk/coursework-writing-services/

Login to post response

Comment using Facebook(Author doesn't get notification)