C# Pass Generics At Runtime
Posted
by TheCloudlessSky
on Stack Overflow
See other posts from Stack Overflow
or by TheCloudlessSky
Published on 2010-04-09T14:26:44Z
Indexed on
2010/04/09
14:33 UTC
Read the original article
Hit count: 272
I have a method like the following:
public IEnumerable<T> GetControls<T>()
: where T : ControlBase
{
// removed.
}
I then created a class:
public class HandleBase<TOwner> : ControlBase
: TOwner
{
// Removed
}
I'd like to be able to call
GetControls<HandleBase<this.GetType()>>;
where it would use the type of THIS class to pass to the HandleBase. This would in essentially get all HandleBase that have an owner of THIS type.
How can I achieve this?
© Stack Overflow or respective owner