473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

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 2132
"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
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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,...

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.