By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,570 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,570 IT Pros & Developers. It's quick & easy.

Type versus Class

P: n/a
I always use the word "class" to describe a class that can be instantiated.
However, I don't get the concept of "Type" or at least I don't know how to
use the word properly. If I have a class called Person, what is its "Type"
and how does it relate to the class?

Thanks in advance.

mark
Nov 16 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Mostly, "class" refers particularly to references types, while "type"
refers to both Reference Types, and Value Types
"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:#u**************@TK2MSFTNGP12.phx.gbl...
I always use the word "class" to describe a class that can be instantiated. However, I don't get the concept of "Type" or at least I don't know how to
use the word properly. If I have a class called Person, what is its "Type" and how does it relate to the class?

Nov 16 '05 #2

P: n/a
So this means I could just as well talk about my "Person type", and just
chuck my previous wording of "Person class?" I'm hoping there is a more
precise difference between the two ...

Thanks again.

Mark

"James Curran" <ja*********@mvps.org> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
Mostly, "class" refers particularly to references types, while "type"
refers to both Reference Types, and Value Types
"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:#u**************@TK2MSFTNGP12.phx.gbl...
I always use the word "class" to describe a class that can be

instantiated.
However, I don't get the concept of "Type" or at least I don't know how to use the word properly. If I have a class called Person, what is its

"Type"
and how does it relate to the class?


Nov 16 '05 #3

P: n/a
A class is a template that defines the members and operations of a
type.

....if that helps! :)

P.
Nov 16 '05 #4

P: n/a
Just out of curiosity, I looked it up in that MSDN glossary:

class
A reference type that encapsulates data (constants and fields) and behavior
(methods, properties, indexers, events, operators, instance constructors,
static constructors, and destructors), and can contain nested types. Class
types support inheritance, a mechanism whereby a derived class can extend
and specialize a base class.

common type system
The specification that determines how the common language runtime defines,
uses, and manages types.

Using the System.Reflection namespace yields a greater appreciation of where
Class ends and Type begins..but to answer your question most use the
phrasing "Person Class" and "Type of Person" interchangeably.

ok,
aq

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:ct**********@titan.btinternet.com...
A class is a template that defines the members and operations of a
type.

...if that helps! :)

P.

Nov 16 '05 #5

P: n/a
Paul E Collins <fi******************@CL4.org> wrote:
A class is a template that defines the members and operations of a
type.

...if that helps! :)


I'm not sure it does, because that describes a struct as well.

To my mind, it's as James described it - class is used for most
reference types (other than delegates, which are just called delegates)
whereas enums and structs are also types.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

P: n/a
There are of course different definitions of a type. If you define a
type as a defined public interface then a class can have zero or more
types. For instance, a class can inherit from Object and implement
IDisposable then the class defines at least two specific public
interfaces, Object and IDisposable.

Class MyClass : Object, IDisposable;
MyClass c= new MyClass(); // object of class MyClass,
// reference var c of type MyClass
Object o= new MyClass(); // object of class MyClass
// ref variable o of type object
IDisposable d= new MyClass(); // object of class MyClass
// ref var d of type IDisposable
Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #7

P: n/a
You may get it this way...

You can have a class called Person, and if you create a new object of type
Person called lobjPerson... you can say that lobjPerson is a object of type
Person.

Regards,
Nirosh.

"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
So this means I could just as well talk about my "Person type", and just
chuck my previous wording of "Person class?" I'm hoping there is a more
precise difference between the two ...

Thanks again.

Mark

"James Curran" <ja*********@mvps.org> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
Mostly, "class" refers particularly to references types, while "type"
refers to both Reference Types, and Value Types
"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:#u**************@TK2MSFTNGP12.phx.gbl...
I always use the word "class" to describe a class that can be instantiated.
However, I don't get the concept of "Type" or at least I don't know

how to use the word properly. If I have a class called Person, what is its

"Type"
and how does it relate to the class?



Nov 16 '05 #8

P: n/a

"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I always use the word "class" to describe a class that can be instantiated.
However, I don't get the concept of "Type" or at least I don't know how to
use the word properly. If I have a class called Person, what is its
"Type"
and how does it relate to the class?


It's fairly simple. a class and a struct are both types.
As a chair and a table are both furniture.


Nov 16 '05 #9

P: n/a
Mark wrote:
I always use the word "class" to describe a class that can be instantiated.
However, I don't get the concept of "Type" or at least I don't know how to
use the word properly. If I have a class called Person, what is its "Type"
and how does it relate to the class?

Thanks in advance.

mark


In some sense, class is just a more complicated type.

Think of struct as something in between.

You can instantiate an Integer() type just as well as any other "class"
-- it's just the class type has both properties and methods.

The idea of a type is a formatted structure.

We speak of /primitive/ types, int, string and so on.
--
Texeme
http://texeme.com
Nov 16 '05 #10

P: n/a
Ricola ! <se****************@tower.effeil> wrote:
Mark wrote:
I always use the word "class" to describe a class that can be instantiated.
However, I don't get the concept of "Type" or at least I don't know how to
use the word properly. If I have a class called Person, what is its "Type"
and how does it relate to the class?

Thanks in advance.
In some sense, class is just a more complicated type.

Think of struct as something in between.


In between what?
You can instantiate an Integer() type just as well as any other "class"
-- it's just the class type has both properties and methods.
Structs can have properties and methods too.
The idea of a type is a formatted structure.
.... with associated behaviour.
We speak of /primitive/ types, int, string and so on.


Actually, string isn't a primitive type.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #11

P: n/a
Type can be understood as a template - in real .Net terms, type is an
abstract class that is capable of encapsulating any class' information
i.e. it can represent a type and can be used to reflect on that class. A
class is a functional entity whereas, a type represents that
functionality.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #12

P: n/a
This may help

Categories of types
Types can be classified with following categories:

primitive types - simplest kind of type e.g. integer and floating-point
number
composite types - types consisting of basic types e.g. abstract data
types
subtype and derived type
function types e.g. binary functions
object types e.g. type variable
class types i.e. type of an object
interfaces i.e. type of a dependency
protocols i.e. type of a communication channel
kinds i.e. type of a type

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.