asp.netvb.netsyntaxbrackets

VB Brackets in Enum?


I'm finding this in some legacy code and just curious what the brackets are for?

Public Enum myEnum
    none = 0
    abc = 2
    def = 4
    ghi= 6
    [jkl] = 8
    mno = 9
End Enum

Solution

  • They're not needed in the example you provided, which I assume you have obscured, but the brackets let you specify a name for an enum item that would otherwise conflict with a reserved word.