Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

What is difference between class and data strcture

What is difference between class and data strcture?
0
N_Sri
Asked:
N_Sri
3 Solutions
 
käµfm³d 👽Commented:
I would venture to say that the difference is insignificant. A data structure is just a way to organise data for efficient transferring and processing. A class can be thought of in the same manner. The only reason I hesitate to say they are one and the same is because you also have the concept of structures (i.e. struct) in C#.
0
 
Éric MoreauSenior .Net ConsultantCommented:
a lot of good resources:
http://msdn.microsoft.com/en-us/library/aa289521(VS.71).aspx
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/6923cbe6-12b7-4e97-a4f5-3d9ebdfc75f2
http://dotnetguts.blogspot.com/2007/07/struct-vs-class-in-net.html

from the second one:
Classes are stored in memory via a heap whereas structs are stored in memory via a stack. Stacks are faster and more efficient and there's no need for the CLR garbage collector ro reclaim memory for structs (which takes time and resources). Structs are value types and all value types are stored on the stack.
 
Basically, classes are reference types and structs are value types. Reference types get stored differently than value types. Value types are stored more efficiently but only when they contain little data.
0
 
N_SriAuthor Commented:
thankyou
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now