I am trying to implement a generic class. It should have a property with an attribute that accepts a compile-time constant that I want to set as the name of the parameter type. Something like that:
namespace Example { public class MyGeneric<T> { [SomeAttribute(CompileTimeConstant)] public int MyProperty { get; set; } private const string CompileTimeConstant = typeof(T).Name;
But since typeof(T).Name is evaluated at runtime, it does not work. Is it possible?
generics reflection c # compile-time compile-time-constant
string QNA
source share