[TL;DR] why const string SomeConstString = SomeEnum.OneEnumValue.ToString(); is not allowed in C# even if it can be processed in compile-time?
Below attribute definition is from Azure WebJobs SDK;
[AttributeUsage(AttributeTargets.Parameter)] [DebuggerDisplay("{DebuggerDisplay,nq}")] public sealed class ServiceBusTriggerAttribute : Attribute { private readonly string _queueName; private readonly string _topicName; private readonly string _subscriptionName; /// <summary> /// Initializes a new instance of the <see cref="ServiceBusTriggerAttribute"/> class. /// </summary> /// <param name="queueName">The name of the queue to which to bind.</param> public ServiceBusTriggerAttribute(string queueName) { ... } And the usage of the code is as below;
public static void GetBapulActivityFromTopic( [ServiceBusTrigger("SomeConstString")] BrokeredMessage message, TextWriter log) { ... } In above usage, I understand that "SomeConstString" should be const string type as the value has to be compile-time constant.
But why SomeEnum.OneEnumValue.ToString() cannot be a compile-time constant?