Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 304
madcolor Avatar asked Mar 08 '26 23:03

madcolor


2 Answers

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.

like image 75
JeffK Avatar answered Mar 10 '26 13:03

JeffK


Brackets are usually used when you want to use a keyword for a variable, classname, function name, or something else where using a keyword would usually be not allowed. Here is a list of the vb.net keywords.

like image 36
Kibbee Avatar answered Mar 10 '26 13:03

Kibbee