Home >>VB.Net Built-in Functions >VB.Net program to print the default values of Enum constants

VB.Net program to print the default values of Enum constants

Write a VB.Net program to print the default initialized values of Enum constants

Here, we create an Enum of Colors and then print the default Enum constant initialized values on the console screen.

Program :

Below is the source code for printing the default initialized values of Enum constants. The program given is compiled and successfully executed.

'VB.Net program to print the default initialized

'values of Enum constants.


Module Module1
    Enum Colors
        WHITE
        ORANGE
        RED
        YELLOW
    End Enum
    Sub Main()
        Console.WriteLine("Values of Enum constants are: ")
        Console.WriteLine("WHITE      : " & CInt(Colors.WHITE))
        Console.WriteLine("ORANGE    : " & CInt(Colors.ORANGE))
        Console.WriteLine("RED   : " & CInt(Colors.RED))
        Console.WriteLine("YELLOW     : " & CInt(Colors.YELLOW))
    End Sub
End Module
	
Output:
Values of Enum constants are:
WHITE : 0
ORANGE : 1
RED : 2
YELLOW : 3
Explanation:

We created a Module1 module in the program above. Here, we have created an Enum Color that includes color names. We printed the default initialized value of Enum constants in the Main() function on the console screen.