Home Inheriting Generic Types
Reply: 0

Inheriting Generic Types

user998
1#
user998 Published in April 23, 2018, 9:31 am

Assumptions

  1. I already know the framework does not allow the pattern to be discussed, in the example
  2. I have a need that would benefit from a more simple application of the Generic pattern.

Context

I am reviewing code for a client and identified a handful of Static/Instance methods that are reliably implemented across several Classes/Structs.

I am looking for an approach, similar to the Example, that will allow for the design described to be performed.

Example

public class StaticObject<T>: T where T: class, new(){
    public void Method1(){}
    public int Method2(){}
}

public class Object : StaticObject<KeyedCollection<string, object>>{

}

Question

What alternative means could i leverage to obtain the ability to have a class inherit from the Generic T and have exposed the two Static methods?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.403557 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO