Enumerators (enum)

enum is a keyword

enum is a collection of integral Constants , which will be Identified with string constants.

enum is a user defined data type.

Syntax to write enum


Enum enum _name


String value =  Integer value,

String value =  Integer value,

String value =  Integer value,


enum must be declared in general declaration (Go) area only.


C language

Int  k = 10; arrrowglobal variable

Main ()


Int I = 10; arrrow local variable


syntax of form1 code window

Using system

Using system.data

Namespace ABC  arrrowproject name








For every project by default a name space will be created with the name of the project.

Using is a keyword which is used to import the namespace (collection of classes )


Ex ample 1 on Enum 

arrrow Open windows forms application project

arrrowPlace a button

arrrowCode for  GD  (general declaration)




Code for button 1 click


Int  I, j, k;

I = (int) GTB. Sa;

j = (int) GTB. Ja;

k = (int) GTB. Ca;


Message Box. Show (I + “” + j + “” + k);


Execute the project



When enum member is not initialized then it will be initialized automatically with incremented value of previous member.

In case previous member is not existing then initialization start from “ZERO”


Example :- A program for developing animated label



To develop this application buttons ,label and timer controls are required.


About Label

Generally label is used to display some text a long with an image [optional].

Label control supports nine types of alignments.



To manage all these alignment , Microsoft introduced a predefined e num  called as content alignment.


About Timer Control

Timer control is used to execute a set of statements continuously provided a property called as Enabled must be true.

Enabled  = true (flase)


Timer tick event will be executed after equal interval which need to be specified in milliseconds   (1000 ms = 1 sec)


Open windows forms application project

Place a button arrrowproperties  F4  arrrowtext = start  arrrowPlace one more button  arrrowproperties arrrowtext   = start

Place a label control arrrowproperties

text  = fish land

text Align  = middle center

Auto size = false

Image = select an image

Place a timer control

Code in GD (Before Button 1 click)


Int I = 0;

Int [] x = new int []  { (int) content Alignment ,

Top center, (int) content Alignment . Middle Right,

(int) content Alignment. Bottom center,

(int) content Alignment. Middle left };

Code for Timer 1 tick (double click on timer)


I = I +1;

If (I = =4)

I =0;


Label 1. Image Align  = (Content Alignment) X [i];


Code for Button 1_ click (Start)


Timer 1 .enabled = true;


Code for button 2_click (stop)


Timer1.enabled = false;