CollectionBase Strong Type

G

Guest

I have a Strongly Typed collection ex:

public class MyClassCollection : CollectionBase
{
.... implemention ....
}

public class MyClass
{}

Is there a way using reflection to get the type the StronglyTyped collection
"MyClassCollection" expects?

Thanks,
 
N

Nicholas Paldino [.NET/C# MVP]

Don

Not really. You aren't required to implement anything beyond what
CollectionBase implements.

You have two ways of doing this. First, you could get the PropertyInfo
for the indexer and see the type that it returns. This assumes you have
indexers on all of your typed collections. The second is to attach an
attribute to the class which exposes the type that it exposes.

Hope this helps.
 
G

Guest

Good idea, becaused we do implement the indexer.

Regards,
--
Don DenUyl
Diamond Systems


Nicholas Paldino said:
Don

Not really. You aren't required to implement anything beyond what
CollectionBase implements.

You have two ways of doing this. First, you could get the PropertyInfo
for the indexer and see the type that it returns. This assumes you have
indexers on all of your typed collections. The second is to attach an
attribute to the class which exposes the type that it exposes.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top