How to use names as an enumeration already used by vb.net as a keyword

I am implementing the show-message extension, which can be found on this blog: http://blogs.taiga.nl/martijn/2011/05/03/keep-your-users-informed-with-asp-net-mvc/

the programmer does a clever reuse of his enum to create css attributes, but in vb.net I am running something strange.

I need this class

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

but the visual studio continues to produce an error in listing errors. Is there a prefix that I can use to tell visual studio how to use the error as an enumeration?

+6
source share
1 answer

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

 Enum Messagetype Succes = 1 [Error] = 2 Notification = 3 End Enum 
+26
source

Source: https://habr.com/ru/post/887959/


All Articles