Declare Enum Element

Adds an element to an existing enumeration. Places the cursor on the generated enum element declaration and drops a marker onto the initial enum element reference.

Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on a reference to an undeclared enumeration element.

Example

public enum MyEnum
{
    element1
}
class TestClass
{
    private void TestMethod()
    {
        var a = MyEnum.element1;
        var b = MyEnum.element2;
    }
}
Public Enum MyEnum
    element1
End Enum
Public Class TestClass
    Private Sub TestMethod()
        Dim a = MyEnum.element1
        Dim b = MyEnum.element2
    End Sub
End Class

Result:

public enum MyEnum
{
    element1,element2
}
class TestClass
{
    private void TestMethod()
    {
        var a = MyEnum.element1;
        var b = MyEnum.element2;
    }
}
Public Enum MyEnum
    element1element2
End Enum
Public Class TestClass
    Private Sub TestMethod()
        Dim a = MyEnum.element1
        Dim b = MyEnum.element2
    End Sub
End Class