Enum in C#

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.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application. After that, add a button in the Form. enum21

Step 2

Go to code editor and add the following code to create the list of enumerators.
  1. public enum EmployeeStatus
  2. {
  3. Active,
  4. Termenated,
  5. Resigned
  6. }

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.
  1. EmployeeStatus Status = EmployeeStatus.Active;
  2.  
  3. switch (Status)
  4. {
  5. case EmployeeStatus.Active :
  6. MessageBox.Show("The Employee's status is Active");
  7. break;
  8.  
  9. case EmployeeStatus.Termenated:
  10. MessageBox.Show("The Employee's status is terminated");
  11.  
  12. break;
  13.  
  14. case EmployeeStatus.Resigned:
  15. MessageBox.Show("The Employee's status is resigned");
  16.  
  17. break;
  18.  
  19. }
  20.  
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

Add new comment