Original: http://z515256164.blog.163.com/blog/static/32443029201192182854300/Have changedC-language explanation-enum typeNote: The following all code execution Environment is VC + + 6.0In a program, you might need to define an alias for some integers, and we can do this with the preprocessing directive # define, and your code might be:#define MON 1#define TUE 2#define WED 3#define THU 4#define FRI 5#define SAT 6#define SUN 7Here, we define a new type
Reference 55049192This explains why an enumeration class cannot be inherited: it has inherited the parent enum class, and its parent implements the serializable interface, which means that all enum classes implement serializationThe Enum class also cannot be inherited for the following reasons:The public enum class nam
C # Idioms:enum or enum class (enum Class)
Marshine
(Original composition format: http://www.marshine.com)
Reversion:2004/5/28
Modification Note: Thanks to the CLS compatibility issue mentioned by Ninputer, while modifying the Equals rewrite not mentioned in the original version, and modifying the imperfect code of "= =" overload and adding the enum struct con
Note: Python version 3.x can be usedEnumeration format:from enum import enumNew Class name = Enum (variable name, variable 1, variable 2 ...)month = Enum (' Month ', (' Jan ', ' Feb ', ' Mar ', ' Apr ', ' may ', ' June ', ' Jul ', ' April ', ' Sep ', ' Oct ', ' Nov ', ' Dec '))1.Seasons = [' Spring ', ' Summer ', ' Fall ', ' Winter ']print (List (enumerate (seaso
Java hidden box operation-enum and hidden box operation enum
Enum, which is an enumeration type, has a similar type in each programming language.
Because it is rarely used, every time I see enum, it will be daunting, because its syntax is really "not playing as usual!
The general
Create a model in which you write a method that gets the enumeration classClass Student extends zend_db_table{protected $_name = ' student ';Protected $_primary = ' id ';function Getpartyenum ($enumname) {Adapter and get the data$db = $this->getadapter ();$db->query ("SET NAMES GBK");$sql = $db->quoteinto (' SHOW COLUMNS from student like ', $enumname);$res = $db->query ($sql)->fetchall ();Processing of the resulting enumeration classGet the enumeration class string$
; } //returns the hash code for the enumeration constant. Consistent with equals, this method cannot be overridden. Public Final inthashcode () {return Super. Hashcode (); } //because enumeration constants are singleton, cloning is not allowed. protected FinalObject Clone ()throwsclonenotsupportedexception {Throw Newclonenotsupportedexception (); } //compares the enumeration constant and the size of the specified object. They are of the same type and return the si
The enum enum type of Java finally appeared in j2se1.5. Before thought it was just a chicken, dispensable. After all these years, without it, don't everyone have a good one? Today, "Thinking in Java" 4th edition, there is a sentence "sometimes precisely because of it, you can" elegant and clean "to solve the problem. Elegance and clarity are important, formally differentiating between successful solutions a
In the actual development, in the database table design, we tend to use an int type state field to represent the status of the data, this field is convenient to represent the state of the data, but do not want to build a foreign key table of the state field to explain the status. (There may be a lot of fields for this type of table state, just for example)We typically use this state field as a convention to apply to the project (for example: 0: Enabled, 1: Disabled)When the actual state of the i
Enumeration is a basic data type in C language, not a data structureUsed to declare a set of constant 1. How to enumerate variables in 3 A. Define the type first, and then define the variable B. Define both the type and the variable C.Anonymous definition enum Season {spring, Summer, Autumn, winter};enum Season s = spring;Variable names that have been positioned as enumerations cannot be used as other varia
type ():Type (v)Returns the type of its is only argument, coded as a string.The possible results of this function is "nil" (a string, not the value nil), "number", "string", "Boolean", "Table", "Fu Nction "," Thread ", and" UserData ".Note: The types of lightuserdata and full UserData are userdata.Type (v) the key source code in Lua is as follows:static int Luab_type (Lua_state *l) { Lual_checkany (L, 1); Lua_pushstring (L, Lual_typename (L, 1)); return 1;} /* Macros to access values *//Get
perspective%. Therefore, the user should design the database in a comprehensive consideration of various factors in order to achieve the best balance # Other string series (efficiency:Char>varchar>text) Text Series TinytextTEXTmediumtext Longtextblob Series Tinyblob BLOB mediumblob longblob binary seriesBINARY VARBINARYtext: The text data type is used to hold large, variable-length strings that can be set up to 65535 (2** -?1) characters. Mediumtext:aTEXT column withA maximum length of -,777,
Js
Author: Junsan Jin
Date: 2005-03-25
E-mail: junsan21@126.com; Junnef21@sohu.com
There are many new features in Jsdk5.0, such as generics, enhanced loops, improved loading, unboxing, static introduction, and so on, which greatly enhances the ease of use of the Java language.
I am now doing a project from the COM + (DCOM) platform to the Java EE platform for porting there are many definitions of enumerated types, which used to be introduced into the third party class library, or write
1. Use an extension method to use an enumeration value for the Description property value Public Static classenumextenstion{ Public Static stringGetdescriptionname ( ThisEnum Enumvalue) {Object[] attr =Enumvalue.gettype (). GetField (Enumvalue.tostring ()). GetCustomAttributes (typeof(DescriptionAttribute),false);if(attr. Length >0)return((DescriptionAttribute) attr[0]). Description;return "";}}2, gets the enumeration Description property value and the enumeration value for the relationship/// /
In the program, we often define constants to identify some states, types, and so on.
For example, define the status of an order, which can be defined as Order_status_cancel = 1 to indicate that the order status is "Order canceled."
But the way the senses define constants is not very flexible,
For example, Order_status_cancel constant means "order canceled", then: when the order data, you can directly use the Order_status_cancel constant to fetch the order data, take out the constant value of 1,
This model is built in models, in which the method of obtaining an enumeration class is writtenDo not pirated, reproduced please add the source Http://blog.csdn.net/yanlintao1Class Student extends zend_db_table{protected $_name = ' student ';Protected $_primary = ' id ';function Getpartyenum ($enumname) {Adapter and get the data$db = $this->getadapter ();$db->query ("SET NAMES GBK");$sql = $db->quoteinto (' SHOW COLUMNS from student?', $enumname);$res = $db->query ($sql)->fetchall ();Processing
When I recently discussed the issue with my colleagues, my colleague suddenly mentioned why the constant values defined in Java do not take the ENMU enumeration type and are defined by the public final static type. We used to be defined in this way, rarely using the enum definition, so also did not pay attention to, in the face of the problem, it is still a little unclear why there is such a definition. If you don't understand, take the time to study
In general, we use the C-style enum keyword to define enumeration types.enum{Uiviewanimationtransitionnone,Uiviewanimationtransitionflipfromleft,Uiviewanimationtransitionflipfromright,Uiviewanimationtransitioncurlup,Uiviewanimationtransitioncurldown,} uiviewanimationtransition;Displacement Operation Enumeration Definitionenum {Uiviewautoresizingnone = 0,Uiviewautoresizingflexibleleftmargin = 1 Uiviewautoresizingflexiblewidth = 1 Uiviewautoresizingflex
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.