473,405 Members | 2,171 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,405 software developers and data experts.

Is Descendent

How do I know if a class is descendent of another one,
not necessaraly his direct parent ?
In my case, I need to know if a certain class descends
from Control.
Thanks for any help.

_____
Marco
Nov 15 '05 #1
3 1412
Just use the "is" operator, like so:

if (myObject is Control) {
// myObject is a Control
}

Hope that helps,
-JG
Nov 15 '05 #2
Juan Gabriel Del Cid <jd*****@atrevido.nospam.net> wrote:
Just use the "is" operator, like so:

if (myObject is Control) {
// myObject is a Control
}


That works for an *instance* of a type. If Marco needs to know the
information just from the type itself, he could use:

if (typeof(Control).IsAssignableFrom (testType))
{
....
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
Thanks Jon and Juan. I will need both ways.

______
Marco
Nov 15 '05 #4

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

Similar topics

4
by: Andy Fish | last post by:
hi, I am using descendent selectors to format cells within a table according to the css class of the table. However, when using nested tables, it seems to pick up the outer matching rule rather...
6
by: Frances Del Rio | last post by:
after searching a lot on google I found what I think is the best (i.e., simplest..) implementation for this, at http://www.alistapart.com/articles/horizdropdowns/ only thing is, I need to make...
3
by: Claire | last post by:
I want to declare a set of descendent exception classes that contains no extra code to the base. It's so I can test the class type of exception and handle its error code differently depending on...
1
by: Jack Addington | last post by:
I have a 3rd party object that fires an itemchanged event when someone edits some data on a form. This event has a custom eventArgs that has a field called ActionCode. In the code of the event,...
0
by: L Scott | last post by:
I've created a page ancestry (framework) for our application so that all pages in our app would have the same look and feel. To do this, I created several user controls (header, footer, menu,...
19
by: Charles Law | last post by:
Take a solution with a project hierarchy along the lines of an n-tier system, so that we have a data layer, business layer and presentation layer. The presentation layer is coupled to the business...
2
by: Bruce HS | last post by:
VS2005, VB. I put some buttons in winform A. I then create form B which inherits A. I want to move the buttons to a different location in form B, but find all properties of the button in the...
4
by: Jamie Hankins | last post by:
I'm probably being dense here. In the following situation: class Base { int x; int y; } class Decendant : Base { int z; }
4
by: Sugan | last post by:
Hi, i came across custom usercontrols in VB 2005 and i'm not clear about the difference between "Me" and "MyBase". 1. What is the difference between the two keywords in a UserControl. 2....
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
0
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...

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.