Tech Off Post

Single Post Permalink

View Thread: Generi type inheritance ????
  • User profile image

    leeappdalecom wrote:
    wait it's all just made sense now lol

    Inherit and extend the capabilities of different types using generics rather than extending every type you have created and it still be the same type of object in the end.

    Exactly! after all this is what generics are all about provide a generic implementation that is specialised at use time.

    So my ipothetical class could become :

    class Snapshot<T> : T , ISnapshot<T> 
     where T : ICloneable
          private T _snapshot;

          Public T SnapShot {
                get {
                      return _snapshot;
          public void SaveSnapshot() {
                _snapshot = this.Clone();

    what you get is your types are extensible in a generic way and also
    specialised without "code copy"