This should help
public class MyUtilClass<T> Where T : MyWellKnownBase, new()
{
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello Team,
This may sound dumb, but not sure if we've any ability to implement Partial Generics in C#. Like, instead of defining a class to be generic, I would like to define a class partial generic. I dont find a way doing this. Am I missing something obvious here or do I have not enough understanding on how Generics are defined.
I was trying to implement class something like this.
public class MyUtilClass<T<MyWellKnownBase>>
{
}
or something like
public class MyUtilClass<MyWellKnownBase<T>>
{
}
This would give me a flexibility to define partial implementation in my util class rather than fully making the class generic of type T.
This should help
public class MyUtilClass<T> Where T : MyWellKnownBase, new()
{
Hello vb2ae,
Appreciate your time and suggestion. I guess that should work. I tried something like below and seems to be what am looking for!
public class Gen1<T>
{
}
public class Gen2<T, K> where T: Gen1<K>
{
}