title: Getting the max value of a custom enum
body: <p>Given the following enum:</p>
  
  <pre><code>public enum SomeEnumType : byte
      {
          [Display(Name = "Name of EnumItemOne")]
          EnumItemOne = 1,
  
          [Display(Name = "Name of EnumItemTwo")]
          EnumItemTwo = 2,
  
          [Display(Name = "Name of EnumItemThree")]
          EnumItemThree = 3,
  
      }
  </code></pre>
  
  <p>I would like to use the maximal number of this enum in a data annotation
  (to validate the input values) using the solution from the following question:
  <a href="https://stackoverflow.com/a/203389/6350813">"Getting the max value of an enum"</a></p>
  
  <pre><code>[DisplayName("Some display name")]
  [Range(1, Convert.ToInt32(Enum.GetValues(typeof(SomeEnumType)).Cast&lt;SomeEnumType&gt;().Max()), ErrorMessage = "Please choose an item")]
  public SomeEnumType SomeField{ get; set; }
  </code></pre>
  
  <p>but I get the following error message:</p>
  
  <blockquote>
    <p>Error CS0182  An attribute argument must be a constant expression,
    typeof expression or array creation expression of an attribute
    parameter type</p>
  </blockquote>
  
  <p>I do not have any idea about the root cause. Has someone faced error message like this?</p>