Home »
VB.Net »
VB.Net Programs
VB.Net program to print the default initialized values of Enum constants
By Nidhi Last Updated : November 16, 2024
How to print the default initialized values of Enum constants in VB.Net?
Here, we will create an Enum of Colors and then print the default initialized values of the Enum constant on the console screen.
Program/Source Code:
The source code to print the default initialized values of Enum constants is given below. The given program is compiled and executed successfully.
VB.Net code to print the default initialized values of Enum constants
'VB.Net program to print the default initialized
'values of Enum constants.
Module Module1
Enum Colors
RED
GREEN
YELLOW
BLUE
End Enum
Sub Main()
Console.WriteLine("Values of Enum constants are: ")
Console.WriteLine("RED : " & CInt(Colors.RED))
Console.WriteLine("GREEN : " & CInt(Colors.GREEN))
Console.WriteLine("YELLOW : " & CInt(Colors.YELLOW))
Console.WriteLine("BLUE : " & CInt(Colors.BLUE))
End Sub
End Module
Output:
Values of Enum constants are:
RED : 0
GREEN : 1
YELLOW : 2
BLUE : 3
Press any key to continue . . .
Explanation:
In the above program, we created a module Module1. Here, we created an Enum Colors that contains the name of colors. In the Main() function, we printed the default initialized value of Enum constants on the console screen.
VB.Net Basic Programs »