Enum in C#
Submitted by janobe on Wednesday, September 26, 2018 - 21:38.
In this tutorial I will teach you how to use enum in c#.net. In this method you will learn how the enum works based on employee’s status. This method is very helpful to use not only for beginner developers but also for professional developers.
For more question about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
FB Account – https://www.facebook.com/onnaj.soicalap
Or feel free to comment below
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application. After that, add a button in the Form.Step 2
Go to code editor and add the following code to create the list of enumerators.- public enum EmployeeStatus
- {
- Active,
- Termenated,
- Resigned
- }
Step 3
Go back to the design view and double click the form to fire the click event handler
of it. After that, do the following code in the method.
- EmployeeStatus Status = EmployeeStatus.Active;
- switch (Status)
- {
- case EmployeeStatus.Active :
- MessageBox.Show("The Employee's status is Active");
- break;
- case EmployeeStatus.Termenated:
- MessageBox.Show("The Employee's status is terminated");
- break;
- case EmployeeStatus.Resigned:
- MessageBox.Show("The Employee's status is resigned");
- break;
- }
Add new comment
- 76 views