Sorry, but you're wrong on most counts. You're thinking of "struct" as
it exists in C++ or C, not C#. C# structs are very different. Read the
links to the threads given in the other posts.
I will try to give a simle answer glossing over as many technical
issues as I can...
Structs are an "old school" method of combineing data elements into one
unit.
In C++ this is true. It is not true in C#. In fact, using them this way
in C# is a sure road to frustration and bad code.
Class came along afterwards, they are esentuly a struct which allows
for things like inheritance and other OO stuff.
Historically, in C++, this is true, but not for C#. Everything changed
in C#.
Structs being somewhat simpler creatures are "lean and mean", that is
they work fast but lack features.
A vast oversimplification that overlooks the primary difference between
struct and class in C#: classes are reference types and structs are
value types. This has implications for how they are assigned, passed to
methods, and returned as results from methods and properties. It also
has implications for garbage collection. All of this means that structs
_may_ give you a performance increase, or _may_ cause performance
degradation, depending upon how you use them.
Unless you understand the difference between value semantics and
reference semantics and why and when one would want one rather than the
other, you will not know where it's appropriate to use a value type
(struct) to gain efficiencies.
Anyway, most value types you'll create will be because you want value
semantics, not for the sake of speed. There are only a few cases I can
think of where something was made a value type for efficiency's sake;
those are Point and Rectangle, and even then the Framework designers
had to make a decision to subtly change their semantics: a Point struct
has different semantic implications from a Point class.
Example .NET stucts Point, Rectangle DateTime. Note how these are
simple operations which are often performance critical.
Well, yes, but you don't say why. The reason is garbage collection: if
you're doing thousands or millions of coordinate calculations, then you
don't want to be stuck garbage collecting thousands or millions of
little Points off the heap. Making it a struct means that it doesn't
need to be GC'd. However, making it a struct changes its semantics
subtly: a Point now becomes a _value_, and as such there's no more
concept of "this point 4,6" as opposed to "that point 4,6". The
coordinates 4,6 become a value that is copied everywhere, just like
"the integer 5". A Point class would give you the possibility of
(cleanly) having several copies of 4,6 that were distinct and could be
manipulated.
Classes are usefull when things get more complicated. Ie you need
inheritance or something.
No... classes are useful when you want reference semantics, which is
almost always, and certainly whenever you have objects that have
_identity_: a customer, a sales order, the sales figures for a
particular year, stuff like that.
struct a = stuct b copyies bto a
class a = class b means a is also called b.
True, but these are hardly "pitfalls": this behaviour is the very
reason why you would choose one over the other.
As I said, please read the other threads that were linked earlier in
this thread. Those discussions clearly outline the pros and cons of
structs versus classes.