Inherit Type Parameter : Generic Type « Generics « C# / C Sharp






Inherit Type Parameter

 


using System;
using System.Collections.Generic;
using System.Text;

public class MyBaseClass<U> {
    private U _parentData;

    public MyBaseClass() { }

    public MyBaseClass(U val) {
        this._parentData = val;
    }
}

public class MySubClass<T, U> : MyBaseClass<U> {
    private T _myData;

    public MySubClass() { }

    public MySubClass(T val1, U val2)
        : base(val2) {
        this._myData = val1;
    }
}

          








Related examples in the same category

1.A generic class with two generic parameters
2.Deserialize generic typeDeserialize generic type
3.Serialization for generic typeSerialization for generic type
4.Nested generic TypesNested generic Types
5. Output the type information about the generic parameters
6.Call ToString on generic type
7.Nested Types
8.combining inheritance of generic types and constraints:
9.A generic Point structure.
10.Reference for Generic Types