Enumeration and Switch Case

enum c# vb.net

Enums are strongly typed constants and very useful in programming when your program needs constant values. It provides efficient way to assign multiple constant integral values to a single variable.


Syntax



Switch Case

C# switch case vb.net

Switch...Case can act upon enum values. The following C# program shows how to Enum work with Switch...case. In the following program , declare an enum backColors.

C#



VB.Net



C# enumaration vb.net

In the paintColor color method , pass enum values and color the background of the form with the help of a switch...case statement.

Source Code | C#



Source Code | Vb.Net





NEXT.....Passing Data