Difference between Class and Structure

Amatya
Posted by in C# category on for Beginner level | Points: 250 | Views : 770 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: Amatya Agyey
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/
Posted by: Chelsieanayas on: 7/5/2017 | Points: 25
Just a smile and the rain is gone Can hardly believe it, yeah. There's an angel standing next to me. Reaching for my heart Just a smile and there's no way back .Can hardly believe it, yeah But there's an angel calling me. Reaching for my heart I know that I'll be okay now. This time, it's real I lay my love on you It's all I wanna do Every time I breathe I feel brand new You open up my heart Show me all your love and walk right through As I lay my love on you.
http://dumbways-todie.com
http://fireboy-andwatergirl.com
Posted by: Happyroom on: 9/21/2017 | Points: 25
I really impress to your all post here is more information for us thanks for sharing this amazing post.
happy room - http://happyroomonline.com
Posted by: Hotmaillogin on: 10/16/2017 | Points: 25
Thanks for sharing these useful information! This is really interesting information for me.
http://hotmailloginproblem.com
Posted by: Amatya on: 10/16/2017 | Points: 25
Thanks @Hotmaillogin
Posted by: Contomlon on: 11/8/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.

1 800 273 8255 lyrics
https://lyricsforme.com/alessia-cara-1-800-273-8255-lyrics

Login to post response

Comment using Facebook(Author doesn't get notification)