471,627 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

CollectionBase Strong Type

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,
--
Don DenUyl
Diamond Systems
Dec 5 '05 #1
2 1305
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Don D" <Do**@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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,
--
Don DenUyl
Diamond Systems

Dec 5 '05 #2
Good idea, becaused we do implement the indexer.

Regards,
--
Don DenUyl
Diamond Systems
"Nicholas Paldino [.NET/C# MVP]" wrote:
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Don D" <Do**@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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,
--
Don DenUyl
Diamond Systems


Dec 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Majed | last post: by
1 post views Thread by Matthew Roberts | last post: by
2 posts views Thread by Samuel R. Neff | last post: by
3 posts views Thread by Tony Johansson | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

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.