473,499 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type of a boxed Object

Hello,

Assume, I got an instance of a certain class that is boxed in an object. How
can I retrieve the type of the original class only using this object. The
type I get with GetType is always System.RuntimeType; the only reference I
can find is over its FullName-property. Is there another way to get the type
info?

Thanks,

Klaus
Nov 20 '05 #1
6 2134
"Klaus Löffelmann" <fo***********@loeffelmann.de> schrieb

Assume, I got an instance of a certain class that is boxed in an
object. How can I retrieve the type of the original class only using
this object. The type I get with GetType is always
System.RuntimeType; the only reference I can find is over its
FullName-property. Is there another way to get the type info?


How do you get System.RuntimeType?
If o.GetType.Fullname returns <yourclass>, it's ok, so o.GetType returns
Gettype(yourclass) which is the type object representing your type.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
"Klaus Löffelmann" <fo***********@loeffelmann.de> schrieb

Assume, I got an instance of a certain class that is boxed in an
object. How can I retrieve the type of the original class only using
this object. The type I get with GetType is always
System.RuntimeType; the only reference I can find is over its
FullName-property. Is there another way to get the type info?


How do you get System.RuntimeType?
If o.GetType.Fullname returns <yourclass>, it's ok, so o.GetType returns
Gettype(yourclass) which is the type object representing your type.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

"Armin Zingler" <az*******@freenet.de> schrieb im Newsbeitrag
news:40***********************@news.freenet.de...
"Klaus Löffelmann" <fo***********@loeffelmann.de> schrieb

Assume, I got an instance of a certain class that is boxed in an
object. How can I retrieve the type of the original class only using
this object. The type I get with GetType is always
System.RuntimeType; the only reference I can find is over its
FullName-property. Is there another way to get the type info?


How do you get System.RuntimeType?
If o.GetType.Fullname returns <yourclass>, it's ok, so o.GetType returns
Gettype(yourclass) which is the type object representing your type.


In the local/auto window it says "System.RuntimeType" for the type of o, but
you're right, though:
If I test it, then

TypeOf o is <yourclass>

returns True.

So, what's the deal with System.RuntimeType, anyway?

Klaus
Nov 20 '05 #4

"Armin Zingler" <az*******@freenet.de> schrieb im Newsbeitrag
news:40***********************@news.freenet.de...
"Klaus Löffelmann" <fo***********@loeffelmann.de> schrieb

Assume, I got an instance of a certain class that is boxed in an
object. How can I retrieve the type of the original class only using
this object. The type I get with GetType is always
System.RuntimeType; the only reference I can find is over its
FullName-property. Is there another way to get the type info?


How do you get System.RuntimeType?
If o.GetType.Fullname returns <yourclass>, it's ok, so o.GetType returns
Gettype(yourclass) which is the type object representing your type.


In the local/auto window it says "System.RuntimeType" for the type of o, but
you're right, though:
If I test it, then

TypeOf o is <yourclass>

returns True.

So, what's the deal with System.RuntimeType, anyway?

Klaus
Nov 20 '05 #5
"Klaus Löffelmann" <fo***********@loeffelmann.de> schrieb
How do you get System.RuntimeType?
If o.GetType.Fullname returns <yourclass>, it's ok, so o.GetType
returns Gettype(yourclass) which is the type object representing
your type.


In the local/auto window it says "System.RuntimeType" for the type of
o, but you're right, though:
If I test it, then

TypeOf o is <yourclass>

returns True.

So, what's the deal with System.RuntimeType, anyway?


Hmmm..no clue.

dim o as object
o = me

in a Form shows "rootnamespace.form1" in the "name" column and "Object" in
the "Type" column. When clicking the [+], the next line also shows
"rootnamespace.form1" in the "Type" column.

VB 2003 BTW

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6
"Klaus Löffelmann" <fo***********@loeffelmann.de> schrieb
How do you get System.RuntimeType?
If o.GetType.Fullname returns <yourclass>, it's ok, so o.GetType
returns Gettype(yourclass) which is the type object representing
your type.


In the local/auto window it says "System.RuntimeType" for the type of
o, but you're right, though:
If I test it, then

TypeOf o is <yourclass>

returns True.

So, what's the deal with System.RuntimeType, anyway?


Hmmm..no clue.

dim o as object
o = me

in a Form shows "rootnamespace.form1" in the "name" column and "Object" in
the "Type" column. When clicking the [+], the next line also shows
"rootnamespace.form1" in the "Type" column.

VB 2003 BTW

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1140
by: Steve | last post by:
Is there a way to dynamically inspect a type for the operators it implements, and then compare two objects implementing that type? Basically I'm looking at a situation where I receive two...
6
501
by: Klaus Löffelmann | last post by:
Hello, Assume, I got an instance of a certain class that is boxed in an object. How can I retrieve the type of the original class only using this object. The type I get with GetType is always...
5
1188
by: AMDRIT | last post by:
I would like to cast an object to a value type specified by a variable of Type Function ReturnTest(InputVar as Object) as Object Dim DataType as Type = GetType(System.String) If TypeOf...
12
13314
by: Just D | last post by:
All, It was possible before in Pascal, C++, etc. to define our custom data type or redefine the existing type, like in Turbo Pascal we could assume that shortint is int and use all references to...
10
3572
by: J055 | last post by:
Hi I have an OrderedDictionary object where the key is an enum. Is there an easy way to cast it to an integer? Examples/document appreciated. Thanks Andrew
70
3284
by: garyusenet | last post by:
I'm using an example piece of code: - namespace Wintellect.Interop.Sound{ using System; using System.Runtime.InteropServices; using System.ComponentModel; sealed class Sound{ public static...
11
1727
by: Brad Pears | last post by:
I am using a function called "CreateSQLParam" which adds SQL parameters to a collection. The function is shown below... I add a parameter to a collection using the following line code... ...
4
2869
by: Brette.Net | last post by:
Hello All, I was doing a little messing around with some type conversion they other day. Code is below. struct ValueStruct { int a; public ValueStruct(int inA)
14
34018
by: GeezerButler | last post by:
For any given type i want to know its default value. There is a neat keyword called default for doing this like object x = default(DateTime); but I have an instance of Type (called someType) and...
15
1377
by: jehugaleahsa | last post by:
Hello: I would like to get default(T). However, I don't know what T is until runtime; I just have a Type. Is there an equivilent means of getting the results of default(T)? Thanks, Travis
0
7132
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
7009
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
7390
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
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3103
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
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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 ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.