【Abstract】several different parameters of the tostring () method of the enum class

Source: Internet
Author: User

This article is taken from the csdn forum post

Q: Question

The tostring () method of the enum class can be different from several parameters, such:
Enum. tostring ("D ");
Enum. tostring ("N ");
Enum. tostring ("G ");
Enum. tostring ("F ");
What do the parameters "N", "g", and "F" mean?

A: Answer

"G" or "G"
If value is equal to a named enumerated constant, the name of the constant is returned; otherwise, the equivalent of the value is returned.

Number.
For example, assume that the unique enumerated constant is named "red" and its value is 1. If the value is set to 1, this format is returned.

Return "red ". However, if the value is set to 2, this format returns "2 ".

-Or-

If the flagsattribute custom attribute is applied to enumeration, the value is considered as a bit field, which contains

Or multiple signs composed of one or more digits.

If value is equal to a combination of named enumerated constants, a list of these constant names separated by delimiters is returned. In

Search for a flag in value, from a flag with the maximum value to a flag with the minimum value. For bitwise fields in the same value

For each identifier, the constant name is connected to the list separated by delimiters. The value of the tag will not be considered, and the next search will continue

.

If value is not equal to the combination of named enumerated constants, the equivalent decimal number of value is returned.

"X" or "X"

Value in hexadecimal format (without leading "0x ").
"D" or "D"

Value in decimal format.
"F" or "F"

The execution of "G" or "G" is the same, but flagsattribute is not required in the enum declaration.

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.