Is there a reasonable approach to “default” type parameters in C# Generics?

前端 未结 5 1002
日久生厌
日久生厌 2020-11-27 18:59

In C++ templates, one can specify that a certain type parameter is a default. I.e. unless explicitly specified, it will use type T.

Can this be done or approximated

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 19:20

    you can also create a class Overload like so

    public class MyTemplate {
        public T1 Prop1 { get; set; }
        public T2 Prop2 { get; set; }
    }
    
    public class MyTemplate : MyTemplate{}
    

提交回复
热议问题