enum is a keyword enum is a collection of integral Constant's, 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.
Interested in mastering .NET? Learn more about ".NET Training" in this blog post.
Int k = 10;
global variable Main () { Int I = 10;
local variable }syntax of form1 code window Using system Using system.data Namespace ABC
project name } } }
Note 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 )
Example 1 on Enum
Open windows form application project
Place a button
Code 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 the incremented value of the previous member.
In case the previous member is not existing then initialization starts from “ZERO”
Example:-
A program for developing the animated label.
To develop this application buttons, labels, and timer controls are required.
Generally, a label is used to display some text along with an image [optional]. Label control supports nine types of alignments.
To manage all these alignments, Microsoft introduced a predefined e num called as content alignment.
The timer control is used to execute a set of statements continuously provided a property called Enabled must be true. Enabled = true (false)
Timer tick event will be executed after the equal interval which needs to be specified in milliseconds (1000 ms = 1 sec)
Open windows forms application project Place a button
properties F4
text = start
Place one more button
properties
text = start Place a label control
properties text = fish land text Align = middle center Auto size = false Image = select an image Place a timer contro
l
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;
}
You liked the article?
Like : 0
Vote for difficulty
Current difficulty (Avg): Medium
1/15
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.
Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox