C# generic with constant

前端 未结 5 1238
借酒劲吻你
借酒劲吻你 2020-12-16 11:36

Is there something similar to this C++ template?

template 
class B
{
    int f()
    {
        return A;
    }
}

I want to mak

5条回答
  •  清酒与你
    2020-12-16 11:59

    C# generics are specialized at run-time, whereas C++ templates are processed at compile-time to make an entirely new type. Given this, the runtime simply doesn't have the features to process non-type parameters (it's not just a C# issue).

提交回复
热议问题