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

Passing a type as a parameter

Hi

I want to write a function that searches a control's ancestors until
it finds a panel of a particular type. I need to do exactly the same
thing for three different types of panels, so I was wondering if it
was possible to pass a type to a function as a parameter?

Thanks :)

Helen
Nov 16 '05 #1
2 18516
Helen <he***@helephant.com> wrote:
I want to write a function that searches a control's ancestors until
it finds a panel of a particular type. I need to do exactly the same
thing for three different types of panels, so I was wondering if it
was possible to pass a type to a function as a parameter?


Yup - just pass an instance of Type.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
I just asked a similar question... you also need to use the typeof method
from the calling method

For instance:

public void FindPanel(Type panelType)
{
.... do the search ...
}

FindPanel(typeof(MyPanelTypeIAmSearchingFor));
"Jon Skeet [C# MVP]" wrote:
Helen <he***@helephant.com> wrote:
I want to write a function that searches a control's ancestors until
it finds a panel of a particular type. I need to do exactly the same
thing for three different types of panels, so I was wondering if it
was possible to pass a type to a function as a parameter?


Yup - just pass an instance of Type.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3

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

Similar topics

2
by: Thomas Philips | last post by:
To experiment with filtering, I define a function f(x,k) as follows >>> def f(x,k=2): return x%k==0 I can check that it works by typing >>> f(10,3) False Now, I try to filter a range using...
3
by: CoolPint | last post by:
I have implemented a generic priority queue below and tested it works fine, but I have one small problem I cannot understand. I have type parameter F which determines the priority so that users can...
2
by: Nautilus | last post by:
Taken from a couple very similar samples on the net, I'm having trouble passing a parameter to a PHP file. Here's all the JS code ... it creates an image object and modifies it's src to make a...
3
by: Martin Montgomery | last post by:
I am passing a System.Type parameter into a method. I would like to create an object of that type from the System.Type. for example public CreateAnObject( System.Type objectType) {...
4
by: Ole Nielsby | last post by:
Here comes a generic class with a static property. Let's say they are exotic singleton pets. abstract class Pet {...} abstract class SharedPet<T>: Pet where T: SharedPet<T>, new() {...
0
by: dawg1998 | last post by:
I am able to populate a DropDownList control within multiple rows of a GridView with the following code: `````````````````````````````````````````````````````` <asp:GridView id="gvGridView"...
1
by: Néstor Sánchez A. | last post by:
Hi, is there a way, maybe using reflection, to use a generic class passing the type parameter dynamicly (not kwnowing the exact type at compile time)? I tried the next example, but doesn't work: ...
2
by: JackC | last post by:
Hi, I create my threads like this: for(int j = 0; j < 5; j++) { boost::thread *thr = new boost::thread(worker_func); threads.add_thread(thr); }
3
by: fxeko | last post by:
Hi all... I have got a problem about passing data parameter in data report VB6 my problem: x= "admin" how to send value of x variabel to data report Thanks for your advabced
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.