473,387 Members | 1,542 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,387 software developers and data experts.

How do I detect that a specific Type is a delegate?

Aimee Bailey
197 Expert 100+
Hi everyone, I guess this question applies to C# too. I am using the Assembly.GetTypes() reflection method to build an object explorer for my project, and for the life of me I can't seem to figure out how to tell a regular class apart from a delegate in my query loop. Any ideas on how I could tell the difference?

It's probably not the hardest thing in the world, but it shows up my lack of current knowledge in reflection, so will be glad to hear from those more experienced in the area :)

---

Ok after a while of playing round I discovered that it's possible to query weather the type has the BaseClass type MulticastDelegate, so made this extension method:

Expand|Select|Wrap|Line Numbers
  1. <Extension()>
  2. Public Function IsDelegate(ByVal aType As Type) As Boolean
  3.     Return aType.BaseType Is GetType(MulticastDelegate)
  4. End Function
  5.  
And it seems to work, however as this is a new subject to me, I am fully aware that this maybe the wrong way to do it, anyone have any thoughts?

Aimee.
Aug 6 '11 #1
0 999

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dan Williams | last post by:
Hi people I understand that Python is strongly, but also dynamically typed. However, I need to create a variable which initially isn't actually set to anything, but still needs to be of a...
2
by: Brett Gerhardi | last post by:
Hi all, I'm trying to something that I'm sure must be possible within the schema language but I cannot seem to work it out. Briefly, I am defining a multi-tiered base structure - each tier has...
4
by: Joe Doyle | last post by:
I'm trying to do this- .... void method1(System.Array arr) { // happen to know all elements in arr are int's // this line throws an InvalidCastException int intArr = (int) arr; }
1
by: Grzegorz Kaczor | last post by:
Hello, I wanted to use Response.TransmitFile to return an image instead of a HTML page. Under IE everything works well, but under Mozilla/Firefox the image is treated as it were text/html. ...
15
by: yxq | last post by:
Hi I want to detect user display type, LCD or CRT, how to do? Thanks
1
by: RobinSword | last post by:
Hi there! I want my VB.NET-program to detect CPU type and speed like: "Intel Pentium 3,06 GHz". How can I do that with VB.NET ? If there is the answer somewhere in the forum: Sorry, I didn't...
0
by: Bishoy George | last post by:
Hi, Is there a way in asp.net so that a page can detect whether it is opened in a pop up window, a normal window or a tab window. -- Bishoy George bishoy@bishoy.com 0102550399
0
by: Bishoy George | last post by:
Hi, Is there a way in asp.net so that a page can detect whether it is opened in a pop up window, a normal window or a tab window. -- Bishoy George bishoy@bishoy.com 0102550399
7
by: Alan T | last post by:
Is there a way to determine what type of file it is? eg. MyDoc.doc returns Word MyDoc.xls or MyDoc.csv returns Excel MyDoc.ppt returns PowerPoint .... etc
15
by: Leandro Ardissone | last post by:
Hi, I want to know what type is a variable. For example, I get the contents of an xml but some content is a list or a string, and I need to know what type it is. Thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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,...

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.