ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

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

Here, we are going to learn how to print the default initialized values of Enum constants in VB.Net?
Submitted by Nidhi, on December 21, 2020

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 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 »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.