What's the diffrence between and class?

L

Larry

Hi, My friends,

Who would like to help me figure out the diffrence between type and class.
In dotnet framework why don't use class, but every type looks very similar
to a class.

What's the diffrence?

I really appreciate your help.

Larry
 
J

Jon Skeet

Larry said:
Who would like to help me figure out the diffrence between type and class.
In dotnet framework why don't use class, but every type looks very similar
to a class.

What's the diffrence?

Every class is a type (in fact, it's a reference type), however there
are also value types, which are types but not classes. Have a look on
page 27 of the ECMA spec partition 1 for a nice diagram showing it all.
 
T

Tom Vande Stouwe MCSD.net

The Type is just a model for holding multiple data items, where a class can
process that information internally. You can overload a class, not a type. A
Class can be used by other processes, where a type is local to the
application. The list of difference goes on, suffice to say. If you need a
structure to simply store data in a single application then a type will do
fine. If not, then you may need (a) class. ;)
Tom

--
==========================================
= Tom Vande Stouwe MCSD.net, MCAD.net, MCP
= 45Wallstreet.com (www.45wallstreet.com)
= (803)-345-5001
==========================================
= If you are not making any mistakes
..= ..you are not trying hard enough.
==========================================
 
B

BenoitM

don't totally understand your question, but will try to answer it anyway ;)

in .net everything is object, but there's two kind of object : reference
type (classes) and value type (structures).

in the .net framework, there's a class named 'Type', but it's used as part
of Reflection , and it represent a type declaration (class, structures,
interfaces, enums, and so on ...) with this class your can obtain many
information about a type : methods, properties, events, etc....
 
J

Jon Skeet

Tom Vande Stouwe MCSD.net said:
The Type is just a model for holding multiple data items, where a class can
process that information internally. You can overload a class, not a type.

No, you overload a method.
A Class can be used by other processes, where a type is local to the
application.

Where are you getting this from? A class *is* a type.
The list of difference goes on, suffice to say. If you need a
structure to simply store data in a single application then a type will do
fine. If not, then you may need (a) class. ;)

Are you confusing struct with type here, perhaps?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top