Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the method of developing enumerated types in C #

Shulou Source: shulou.com Published: 2022-06-02 08:38:52 09月22日 Update

This article mainly explains "what is the method of C#enumeration type development", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "what is the method of C#enumeration type development"!

C#enumeration type development learning experience finally use C#to formally write my *** program, because of C#is not very familiar, so I intend to write a simple inventory system. Business is also relatively simple, that is, purchase orders, advance and retreat orders, sales orders, sales return orders, inventory orders. Therefore, I defined a document C#enumeration type:

public enum Doc Type//C#Enumerated types {Purchase Doc = 0, Advance/Withdrawal Doc = 1, Sales Doc = 2, Return Doc = 3, Inventory Doc = 4 }

C#enumeration type development learning experience: in C#can be very convenient to define a Chinese name of this enumeration type, which is not allowed in Delphi 7, so that I can easily understand the role of this type literally. Now, I want to put all document types into a ComboBox for the user to choose from. All I need is:

ComboBoxEdit1.Properties.Items. AddRange(System.Enum.GetValues(typeof));

Run the program and select ComboBoxEdit1. All document types are listed in ComboBoxEdit1. Since C#is more OO than Delphi, I only need to obtain EditValue directly to obtain the currently selected document type (see below). In Delphi, since we can only get the Text attribute of ComboBox1, we must use case statements to convert document types one by one.

C#Enumeration Types Document Types for Development and Learning

djlx = (Doc Type)ComboBoxEdit1.EditValue;

More importantly, if a new document type needs to be added due to business changes, we only need to directly add a document type (such as transfer document) to the document type enumeration. Run the program again and you will find that ComboBox1 automatically contains new transfer orders!

At this point, I believe that everyone has a deeper understanding of "what is the method of C#enumeration type development", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Type document Cellular development method learning program selection business content I want transfer order plus one inventory run advance and retreat sales practical deeper important Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Linux Apple Shulou Tech Info