title: Verifying enum value is valid in VB.NET
body: <p>My English may not be very good, so please excuse me if I don't make sense.</p>
  
  <p>I am tasked with verifying an Enum contains a incrementing value.</p>
  
  <p>The code looks like this:</p>
  
  <pre><code>Public Enum AccountMessageDescriptor
    AccountInvalid = 1001
    AccountReviewPending=1002
    ...
    InvalidOperationOnAccount=1382
  End Enum
  </code></pre>
  
  <p>Each Enum value has a description (Custom) attribute also. The file and description attribute is used elsewhere... It looks like the programmers update the enums and use the custom attribute for help messages instead of resource files etc with a new integer value...</p>
  
  <p>For example, another error may be added as:</p>
  
  <p>NewEnumItem=1383</p>
  
  <p>I need to make sure (during build time we have a custom MSBuild task that does lots of other processing) if the enum is incrementing sequentially and that its not already in use.</p>
  
  <p>Someone suggested using a collection, check if the enum value already exists and if not insert it.</p>
  
  <p>I was thinking of just iterating through and checking if the current value is +1 the previous value (so its sequential and it can't be already in use because it has to always be +1). Does this seem flawed or am I not understanding something about .NET enums?</p>
  
  <p>Emmi</p>