Unique strength of enumeration, unique strength of enumeration
Enumeration
The enumerated type Declaration defines a type name for a group of related symbol constants. Enumeration is used for "Multiple Choices", that is, when the program is running,
In practical problems, the values of some variables are confined to a limited range. For example, in one weeks only seven days, only 12 months a year, gender only male and female and so on. It is obviously inappropriate to describe these quantities
. NET basic step by step: [methods, structures, enumeration],. net basic structure Enumeration
Methods, structures, and enumeration
Method:
A mechanism for reusing a bunch of code.
Syntax:
[Access modifier] return type (parameter list ){
Method
Research on enumeration in C # (skip some small pitfalls of net ),
Previously, I used Enum. Parse () to convert the string into enumeration. I did not go into detail. I found a problem later, and I had a preliminary study on the Enum below (. net 4.0
Enumeration
The enumerated type Declaration defines a type name for a group of related symbol constants. Enumeration is used for "Multiple Choices", that isProgramThe runtime is determined by the fixed number of "Choices" that have been set at the
The members in the structure can be assigned values. What about enumeration... is a value, read-onlyYou can create a class as a structure in the following situations:(1) If there are very few fields in a class, the total memory occupied by all
Introduction to data types in C # (enumeration) The definition of an enumerationChar.">According to the definition given on MSDN, an enumeration is a specified set of constant numbers whose underlying type can be any integral type except char. Int32
Http://msdn.microsoft.com/zh-cn/library/ms229058 (vs.80). aspx
Http://msdn.microsoft.com/zh-tw/library/sbbt4032.aspxEnumeration Design
Enumeration provides Group constant values, which help to make members of a strong type and improve code
Why do enumeration values in C # Use the power of 1,2,4,8,16,32, such as 2, to use 1,2,4,8,16,32, such as 2, to prevent duplication.. NET enumeration we generally have two usages, one representing the unique sequence of elements, such as the days of
Enumerated types defines a pair of "Symbol names/values.For example, the following Color type defines a set of symbols, each of which identifies a Color:
Red, Green, Blue, Orange }
1) Enumeration type makes the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.