Constructed type: array \ enum \ struct #import struct: Constructed type, is a custom type.struct cpoint//struct is a keyword used to declare that a struct is followed by the name of a struct. The contents of the curly braces are called member variables//{float x;Float y;};//with a semicolon-terminated typedef struct car{Char name[20];int number;Float score;}ca;s
Enumeration type (also called enumeration) is a very interesting value type. It not only improves the readability of the program, but also reduces program changes caused by business changes.
In addition, the enumeration type is strongly typed. The accept method must have the same matching parameter. Otherwise, an error will occur.
Well, let's just put it bluntly.
The rest API requires that the LifeCycle field of the Requster json be filled with only young and old, and for the other lifeCycle, return the bad request message to requester.public class DataCategory {LifeCycle LifeCycle;public void Setlifecycle (LifeCycle LifeCycle) {This.lifecycle = lifeCycle;}Public LifeCycle getlifecycle () {return lifeCycle;}Public String GetName () {return name;}public void SetName (String name) {THIS.name = name;}String name;public static void Main (String args[]) {Data
: Playground-noun:a place where people can playimport uikitenum month:int{ //So defined, after the Feb, Mar will automatically be assigned a value of 2 and 3 . Case Jan = 1, Feb, Mar, APR, May, June, July, Dec}let, Sep, Oct, Nov, Currentmonth:month =. nov//View the value of the enumeration currentmonth.rawvalue//the enumeration variable created by this method is a selectable variable. After unpacking, use let Nextmonth = Month (rawvalue:12) nextmonth!. rawvalue//example var userinputnumber
When writing the switch code in Java, the parameters are in string, JDK use is 1.8, but still error, said does not support the 1.7 version of the following, and then find some files in the project, open a file as follows, found to be 1.6 version, it is very strange ah, according to the eclipse hint, the version of 1.7, you can.Cannot switch on a value of type String for source level below 1.7. only convertible int values or
voidMain(){newEnumForeach().Foreach();}publicclassEnumForeach{publicvoidForeach(){foreach(Status iteminEnum.GetValues(typeof(Status))){item.ToString().Dump();((int)item).Dump();}}}publicenum Status{AA = 1,BB = 2,CC = 3}
It is sometimes necessary to iterate through the enumeration types in development, for example, when I am dealing with a problem, I need to convert the integral type to the corresponding enumeration
reference Advanced, reference advanced add#include Auto Auto variable automatically creates data based on type #include Bool#include EnumC is a weak type and does not do type checking. C + + is a strong type and requires more rigor. Enum.c#include Enum.cpp#include newdelete Global #include Big Data multiplication and
ASP.net has been used to enumerate many places in project development, and to display the enumeration to the Drop-down list box Our usual method is to add one to the Drop-down list control. It's okay to do this, but if the enumeration value in my enumeration type changes, then you have to look around the way and then change it.
Here I have the reflection dynamic binding enumeration value can be easily modified, the code is as follows:
public
With multiple selection paths, you can use a switch to make your program more concise and efficient. However, because it can only judge the integer selection factor, so it restricts its use in other types, especially string, this article utilizes the new enum of JDK1.5 to implement a method that can switch the string type. See code directly: enumenumexample {Teamreq,Matreq;} publicclass enumtest{publicstati
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.