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

GetConstructor on Generic Classes.

Given the following example class:

public class genericClass<T>
{
public genericClass() {}
public genericClass(IEnumerable<Ta) { /* do something with a
*/ }
public genericClass(T b) { /* do something with b */ }
}

And the following code:

Type t = typeof ( genericClass<testClass);

Is there anyway to call t.GetConstructor to get the ConstructorInfo
about the constructor genericClass(IEnumerable<Ta) ? At the point I
want to call GetConstructore I also have a Type class describing
testClass if that helps.

Thanks

Nick

Mar 6 '07 #1
2 2960
Undergrid wrote:
Given the following example class:

public class genericClass<T>
{
public genericClass() {}
public genericClass(IEnumerable<Ta) { /* do something with a
*/ }
public genericClass(T b) { /* do something with b */ }
}

And the following code:

Type t = typeof ( genericClass<testClass);

Is there anyway to call t.GetConstructor to get the ConstructorInfo
about the constructor genericClass(IEnumerable<Ta) ? At the point I
want to call GetConstructore I also have a Type class describing
testClass if that helps.
You should be able to. Have you tried using
'typeof(IEnumerable<>).MakeGenericType(typeof(test Class))' as the
argument type?

-- Barry

--
http://barrkel.blogspot.com/
Mar 6 '07 #2
On 6 Mar, 11:09, Barry Kelly <barry.j.ke...@gmail.comwrote:
>
You should be able to. Have you tried using
'typeof(IEnumerable<>).MakeGenericType(typeof(test Class))' as the
argument type?

-- Barry

--http://barrkel.blogspot.com/
Thank you Barry, that does the job nicely. I knew there had to be a
way to do it, I just couldn't figure out how.

Thanks

Nick

Mar 6 '07 #3

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

Similar topics

3
by: Jim Newton | last post by:
hi all, i'm relatively new to python. I find it a pretty interesting language but also somewhat limiting compared to lisp. I notice that the language does provide a few lispy type nicities, but...
17
by: Andreas Huber | last post by:
What follows is a discussion of my experience with .NET generics & the ..NET framework (as implemented in the Visual Studio 2005 Beta 1), which leads to questions as to why certain things are the...
6
by: Robin | last post by:
Are there any generic classes available that can be used in VB.Net to perform common tasks such as Database Access and Logging?
6
by: Urs Eichmann | last post by:
While experimenting with the Feb CTP Edition of VB 2005, I came across "generic procedures". You can write: Public Class Foo Public Sub MySub(Of tDisp As IDisposable)(ByVal vMyParm As Integer)...
25
by: Lars | last post by:
Hi, I have a base class holding a generic list that needs to be accessed by both the base class and its subclasses. What is the best solution to this? I am fairly new to generics, but I am...
3
by: Tigger | last post by:
I have an object which could be compared to a DataTable/List which I am trying to genericify. I've spent about a day so far in refactoring and in the process gone through some hoops and hit some...
3
by: =?Utf-8?B?YnVsbDIwMDBAbmV3c2dyb3VwLm5vc3BhbQ==?= | last post by:
here is the simplified code: the myCor is set to null when run the program. but if remove the "ref" from the constructor's parameter, myCor gets a valid value. Please help!!! thanks. Type...
5
by: Torben Laursen | last post by:
I am writing a COM in C# using visual studio 2005 and VSTO. Inside the code I use some support classes that are generic but they are not used in the inferface of the COM. However I still get a...
10
by: phancey | last post by:
I'm quite new to generics. I have 2 generic classes: MyClass<Tand MyOtherClass<T>. MyClass<Thas 2 public Add methods Add(MyOtherClass<T>); Add(MyOtherClass<Wrapper<T>>); (Wrapper<Tis another...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.