Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of developing enumerated types in C #

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report