Enumeration and constants

Source: Internet
Author: User

Directory

First, we will introduce the differences between the two.

1. A constant is a value, and an enumeration is a set of unchanged values.

2. enumeration is defined by yourself before use. There are certain constraints and constants can be defined at will.

3. If the input value of enumeration is a fixed value, no error will occur. The constant is a value and the passed parameter is arbitrary.

4. restrict users from assigning values at will. You can only select values in the enumerated values. You do not need to memorize each value. You only need to select the corresponding value.

Advantages of enumeration:
Enumeration makes the code easier to maintain and helps to specify valid and expected values for the variable.

Enumeration makes the code clearer. descriptive names are allowed to represent integer values, rather than fuzzy numbers.

Enumeration makes the code easier to type. When assigning values to enumeration instances, VS. net ide uses intelliisense to pop up a list box containing acceptable values, which reduces the number of buttons and allows us to recall possible values.

 

Reference resources:

Http://www.cnblogs.com/daniel206/archive/2008/01/16/1041745.html

Http://blog.sina.com.cn/s/blog_6f3da82b01011oxd.html

Http://zhidao.baidu.com/question/112136992.html

Http://www.cnblogs.com/yank/archive/2009/02/27/1399423.html

 

 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.