15

I'm wanting to know to get Intellisense in Visual Studio 2005 to display the meaning of individual enum values for a VB.NET project. This already happens for enums that are a part of the .NET library.

Is this possible? If so, how would I need to comment my enums to get this to happen?

3 Answers 3

16

In VS 2008 simply use the standard XML commenting syntax. I assume (but have no way of checking) that it's the same in VS 2005?

    ''' <summary>
    ''' Overall description
    ''' </summary>
    Public Enum Foo AS Integer
        ''' <summary>
        ''' Specific value description
        ''' </summary>
        First,
        ''' <summary>
        ''' etc.
        ''' </summary>
        Second
    End Enum
2
  • 4
    In VB.NET use ''' instead of ///
    – M4N
    Commented Sep 1, 2010 at 19:39
  • Thank you @jball, this does exactly what I want.
    – user65628
    Commented Sep 1, 2010 at 19:47
7

In C#, you do it like this:

enum Test
{
    /// <summary>
    /// The first value.
    /// </summary>
    Val1,
    /// <summary>
    /// The second value
    /// </summary>
    Val2,
    /// <summary>
    /// The third value
    /// </summary>
    Val3
}

So, in VB you would just add the XML comment summary above the enum value.

0

In case someone else finds this and has the same problem...

This doesn't work when you assing values like this, only the first summary will be shown.

''' <summary>
''' Overall description
''' </summary>
Public Enum Foo AS Integer
    ''' <summary>
    ''' Specific value description
    ''' </summary>
    First = 0
    ''' <summary>
    ''' Does not show up!
    ''' </summary>
    Second = 1
End Enum

Just add an empty row before every new summary and it works:

''' <summary>
''' Overall description
''' </summary>
Public Enum Foo AS Integer
    ''' <summary>
    ''' Specific value description
    ''' </summary>
    First = 0

    ''' <summary>
    ''' Does now show up!
    ''' </summary>
    Second = 1
End Enum

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.