TypeOf vs. GetType 
Author Message
 TypeOf vs. GetType

What is the difference between TypeOf and GetType?

TypeOf is a keyword and GetType is an operator.  But, what does that
mean?  What is the semantic difference?

And, what about the System.Type class and Object's GetType
implemention.

Thanks,

Isaac



Wed, 21 Sep 2005 05:36:19 GMT  
 TypeOf vs. GetType
Hi Isaac,

TypeOf is usually used in comparison operations, such as the following:

If TypeOf MyControl Is TextBox Then
    ' The control is a textbox
Else
    ' The control is something else
End If

GetType returns the type of the specified object, used in many situations
including serialization and other systems where the type of object is
needed.

An object's GetType implementation is basically the same as the GetType
operator:

... GetType(x) ...
and
... x.GetType ...

--
==============================================
Happy to Help,
Tom Spink

http://dotnetx.betasafe.com > .NET code (soon)

One Day,

Quote:
> What is the difference between TypeOf and GetType?

> TypeOf is a keyword and GetType is an operator.  But, what does that
> mean?  What is the semantic difference?

> And, what about the System.Type class and Object's GetType
> implemention.

> Thanks,

> Isaac



Wed, 21 Sep 2005 06:46:08 GMT  
 TypeOf vs. GetType

Quote:
> What is the difference between TypeOf and GetType?

> TypeOf is a keyword and GetType is an operator.  But, what does
> that mean?  What is the semantic difference?

> And, what about the System.Type class and Object's GetType
> implemention.

TypeOf checks if the object is of the given type, derived from that, or
implements the interface.

GetType returns a System.Type object.

--
Armin



Wed, 21 Sep 2005 05:52:08 GMT  
 TypeOf vs. GetType
What is the difference between TypeOf and GetType?

TypeOf is a keyword and GetType is an operator.  But, what does that
mean?  What is the semantic difference?

And, what about the System.Type class and Object's GetType
implemention.

Thanks,

Isaac



Fri, 23 Sep 2005 21:25:56 GMT  
 TypeOf vs. GetType

Quote:
> What is the difference between TypeOf and GetType?

> TypeOf is a keyword and GetType is an operator.  But, what does
> that mean?  What is the semantic difference?

> And, what about the System.Type class and Object's GetType
> implemention.

Didn't you find the answers you got from Tom and me?

Armin



Fri, 23 Sep 2005 22:03:23 GMT  
 TypeOf vs. GetType
On Mon, 7 Apr 2003 16:03:23 +0200, "Armin Zingler"

Sorry, yes I did.  I didn't see my post in a few days so I thought it
got lost and went wherever socks in a dryer go :-).  So, I reposted.
Thanks for your help, it answered it exactly.

--Isaac

Quote:

>Didn't you find the answers you got from Tom and me?

>Armin



Sat, 24 Sep 2005 02:13:31 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Assembly.GetTypes problem in Final Release vs Release Candidate

2. Structures, GetType

3. Option Strict and GetType

4. GetType

5. in a control, Me.FindForm.GetType fails to return correct type at design time

6. document object of brswer control only has .GetType method in vb.net

7. Can't GetType from DLL

8. DLL Can't GetType

9. Problem with Type.GetType()

10. type.gettype

11. Type.GetType Failure

12. TabPage Collection of Controls and GetType

 

 
Powered by phpBB® Forum Software