开发者

How to use names as enum that are already used by vb.net as keyword

开发者 https://www.devze.com 2023-03-05 18:06 出处:网络
I am implementing the show-message extension fo开发者_开发知识库und on this blog: http://blogs.taiga.nl/martijn/2011/05/03/keep-your-users-informed-with-asp-net-mvc/

I am implementing the show-message extension fo开发者_开发知识库und on this blog: http://blogs.taiga.nl/martijn/2011/05/03/keep-your-users-informed-with-asp-net-mvc/

the programmer makes clever reuse of his enum to build css attribuuts but in vb.net i run on something strange.

I need this class

Enum Messagetype
    Succes = 1
    Error = 2
    Notification = 3
End Enum

but visual studio keeps giving an error on the Error enum. Is there a prefix i can use to tell visual studio its ok to use error as enum ?


You could wrap reserved words in [] in VB.NET (the same as the @ in C#):

Enum Messagetype
    Succes = 1
    [Error] = 2
    Notification = 3
End Enum
0

精彩评论

暂无评论...
验证码 换一张
取 消