开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜