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

前端 未结 5 996
日久生厌
日久生厌 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:23

    C# does not support such a feature.

    As you said, you can subclass it (if it's not sealed, and duplicate all constructor declarations) but it's a completely different thing.

提交回复
热议问题