Enum to String in VB.NET

vb.net

Solution

try this:

Private CALLING_APP As Applications= Applications.CC    ' no "Const"
' CALLING_APP.ToString will return CC

`Const` can apparently change how NET recognizes the constant. As a Const, I get `Cannot find the method on the object instance` while Intellisense "sees" it correctly. If you must use `Const` for some reason, you can get the text return this way:

Dim strName as string = [Enum].GetName(GetType(Applications), CALLING_APP ))

It is basically what .ToString does for us behind the scenes. Typed as it is, your code should work.

Problem

I have this enumeration ``` Public Enum Applications Unknown = 0 AA = 1 BB = 2 CC = 3 End Enum Private Const CALLING_APP As Applications= Applications.CC ``` CALLING_APP.ToString() is giving me "3". But I want "CC" - what am I doing wrong?

Original source

Related problems