Wednesday, 2 November 2016

VB.NET - Enum - get number of elements (lenght of enum)

Watch this example on YouTube


    Public Enum SomeEnum
        Bob = 1
        Frank = 2
        Gary = 3
        Taras = 4
        Oleh = 5
    End Enum

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim num As Integer = [Enum].GetNames(GetType(SomeEnum)).Length
        MessageBox.Show(num)
    End Sub

No comments:

Post a Comment