Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Comparing object types

0 views
Skip to first unread message

HelgeS

unread,
Jan 8, 2004, 3:43:27 PM1/8/04
to
I want to determin if objectA is of the same type as
objectB, or is inherrited from the same type.

I hav tried something like
Type objectAType = objectA.GetType();
if(objectB is objectAType)
....

That does not work, because the "is" statement requires a
class name and not a object of type "Type".

Any suggestions?

HelgeS

Gianluca Varenni

unread,
Jan 8, 2004, 5:20:02 PM1/8/04
to
Hi.

I think you can use the method Type.IsInstanceOfType(). If you look at the
.NET SDK documentation on that method, you can find an example that shows a
good example of its use.

Have a nice day
GV


"HelgeS" <anon...@discussions.microsoft.com> wrote in message
news:022f01c3d628$111f84a0$a501...@phx.gbl...

anon...@discussions.microsoft.com

unread,
Jan 8, 2004, 5:37:24 PM1/8/04
to
That solved it.
Thanks a lot!

Have a nice day

HelgeS

>-----Original Message-----
>Hi.
>
>I think you can use the method Type.IsInstanceOfType().
If you look at the

>..NET SDK documentation on that method, you can find an

example that shows a
>good example of its use.
>
>Have a nice day
>GV
>
>
>
>
>"HelgeS" <anon...@discussions.microsoft.com> wrote in
message
>news:022f01c3d628$111f84a0$a501...@phx.gbl...
>> I want to determin if objectA is of the same type as
>> objectB, or is inherrited from the same type.
>>
>> I hav tried something like
>> Type objectAType = objectA.GetType();
>> if(objectB is objectAType)
>> ....
>>
>> That does not work, because the "is" statement
requires a
>> class name and not a object of type "Type".
>>
>> Any suggestions?
>>
>> HelgeS
>
>

>.
>

0 new messages