473,508 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type versus Class

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
12 1567
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
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
A class is a template that defines the members and operations of a
type.

....if that helps! :)

P.
Nov 16 '05 #4
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
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
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
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

"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
8674
by: Kevin | last post by:
Hi! I recently completed a graduate level Java class at a local university. For our class project my group built a web-based application. Basically, the application would let a manufacturing...
5
2982
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
2
2799
by: BillyO | last post by:
I need a general mechanism for passing parameters to an API function I am designing, call it foo. Foo processes data, the operation used to process the data and the parameters for that operation...
17
1610
by: johny smith | last post by:
I never really know if I should use references or pointers for constructors. Can anyone give me some guidance on when to use what? My back ground is C, so I tend to use pointer notation, but...
2
6717
by: Andrew Robinson | last post by:
I need to create a shared static field for use within a number of different classes. Which one should I be using or are they all really the same thing? public class Widget { private Widget() {}...
8
1244
by: John Granade | last post by:
I'm sure this has been asked but after searching the Internet, I just can find a clear answer. When should you add a component versus a class to you Windows Forms application? The timer is a...
669
25396
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
59
12173
by: peter.tornqvist | last post by:
Maybe I'm stupid or maybe I am missing the obvious, but I can't find a way to define a type alias in C# for primitive types (class and interfaces I can inherit from, no problem). I.e I want to...
13
4986
by: blangela | last post by:
I have decided (see earlier post) to paste my Word doc here so that it will be simpler for people to provide feedback (by directly inserting their comments in the post). I will post it in 3 parts...
0
7228
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7128
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.