enum

MySQL的数据类型

随声附和 提交于 2019-12-03 05:15:29
一.数值类型 Mysql支持所有标准SQL中的数值类型,其中包括严格数据类型(INTEGER,SMALLINT,DECIMAL,NUMBERIC),以及近似数值数据类型(FLOAT,REAL,DOUBLE PRESISION),并在此基础上进行扩展。 扩展后增加了TINYINT,MEDIUMINT,BIGINT这3种长度不同的整形,并增加了BIT类型,用来存放位数据。 整数类型 字节 范围(有符号) 范围(无符号) 用途 TINYINT 1字节 (-128,127) (0,255) 小整数值 SMALLINT 2字节 (-32 768,32 767) (0,65 535) 大整数值 MEDIUMINT 3字节 (-8 388 608,8 388 607) (0,16 777 215) 大整数值 INT或INTEGER 4字节 (-2 147 483 648,2 147 483 647) (0,4 294 967 295) 大整数值 BIGINT 8字节 (-9 233 372 036 854 775 808,9 223 372 036 854 775 807) (0,18 446 744 073 709 551 615) 极大整数值 FLOAT 4字节 (-3.402 823 466 E+38,1.175 494 351 E-38),0,(1.175 494 351 E-38,3

C#解析深浅拷贝

99封情书 提交于 2019-12-03 04:20:58
前言   前面我们学习完了设计模式,在其中我们有了解到原型模式。这里涉及到了克隆自身对象。那么也就是对对象进行拷贝。这里就涉及到了这么一个概念。深浅拷贝、何为深拷贝何为浅拷贝呢?我们一起来看看吧。 浅拷贝   首先我们看看浅拷贝。浅拷贝就是将对象中的所有字段复制到新对象中去,浅拷贝对于值类型和引用类型有不同的影响。值类型的值被复制到副本中后,修改副本中的值不会影响原来对象的值。然而引用类型被复制到副本中的是引用类型的引用。不是引用的对象。这样再修改副本中的值是会导致原来对象的值也被修改了。但是这里引用类型情况我们需要排除字符串 String类型。   那么为何引用类型修改副本的值会造成原来对象的值的变化,而 string字符串类型却排除在外呢?首先我们需要知道这么一个概念,string类型是一个不可变的数据类型,也就是意味着对字符串对象进行了初始化,该字符串对象就不能改变了。表面上我们修改字符串的内容的方法和运算实际上是创建了一个新字符串,然后根据需要可以把旧字符串的内容复制到新字符串中。怎么理解你?我们看下面这个案例: #region 字符串比较 /// <summary> /// 获取引用类型的内存地址方法 /// </summary> /// <param name="o"></param> /// <returns></returns> public static

设计模式实战——策略模式

泪湿孤枕 提交于 2019-12-03 04:19:38
最近本来想优化一个单查为批量查询,然后一顿侧滑之后,反而改了下别人策略的实现,具体的工厂方法实现如下: @Component public class TestFactory implements InitializingBean, ApplicationContextAware { private ApplicationContext applicationContext; public static Map<TestEnum, AbstractConsignTab> strategyMap = Maps.newConcurrentMap(); @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } @Override public void afterPropertiesSet(){ Map<String, AbstractConsignTab> childList = applicationContext.getBeansOfType(AbstractTestTab.class); for (Map.Entry<String,

Using enum as a dependency property in WPF

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I try to use enum type as a dependency property in my custom control, but always get an error: public enum PriceCategories { First = 1, Second = 2, Third = 3, Fourth = 4, Fifth = 5, Sixth = 6 } public static readonly DependencyProperty PriceCatProperty = DependencyProperty.Register("PriceCat", typeof(PriceCategories), typeof(CustControl), new PropertyMetadata(PriceCategories.First)); }; public PriceCategories PriceCat // here I get an error "Expected class, delegate, enum, interface or struct" { get { return (PriceCategories)GetValue

Why can&#039;t enum constructors be protected or public in Java?

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The whole question is in the title. For example: enum enumTest { TYPE1(4.5, "string1"), TYPE2(2.79, "string2"); double num; String st; enumTest(double num, String st) { this.num = num; this.st = st; } } The constructor is fine with the default or private modifier, but gives me a compiler error if given the public or protected modifiers. 回答1: Think of Enums as a class with a finite number of instances. There can never be any different instances beside the ones you initially declare. Thus, you cannot have a public or protected constructor,

nested enum-why is it used?

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have seen constructs with an enum declared inside an enum. What is this used for ? 回答1: Enums in Java can't be extended, so if you wanna collate strongly-related enums in one place you can use these nested enum constructs. For example: public enum DepartmentsAndFaculties { UN (null, "UN", "University"), EF (UN, "EF", "Engineering Faculty"), CS (EF, "CS", "Computer Science & Engineering"), EE (EF, "EE", "Electrical Engineering"); private final DepartmentsAndFaculties parent; private final String code, title; DepartmentsAndFaculties

How do I set enum data type in doctrine 2

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In annotation based mapping, as per the documentation of doctrine, we can do as shown below: /** @Column(type="string", columnDefinition="ENUM('visible', 'invisible')") */ My question is how do I represent this in yaml meta data file for doctrine? I want to do something like this: fields: status: type: string columnDefinition: .... I am using symfony 2 as framework 回答1: Just use: fields: status: type: string columnDefinition: ENUM('visible', 'invisible') 回答2: status: type: enum values: ['visible', 'invisible'] http://docs.doctrine-project

What is the access level of variables in enums by default [duplicate]

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: In Java, difference between package private, public, protected, and private 26 answers Recently I've come across the following piece of code: enum Animals { DOG("woof"), CAT("meow"), FISH("burble"); String sound; Animals(String s) { sound = s; } } class TestEnum { static Animals a; public static void main(String[] args) { System.out.println(a.DOG.sound + " " + a.FISH.sound);//Expected compilation failure } } I would expect the code to fail to compile because of this a.DOG.sound part. But to my

How is interpreted an enum type with EF Code First

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here is a model: Public class Person { [Key] Public int PersonId { get; set: } Public int Age { get; set; } Public ColorEnum FavoriteColor { get; set; } } Public Enum ColorEnum { Red = 1, Green = 2, Blue = 3 } Is it possible for Entity Framework Code First to use the Person model to generate the corresponding table? What about the ColorEnum type? Thanks 回答1: EF 4.3 doesn't support Enums. But is has been announced that Enum support is coming with EF 5 , which is due out alongside .NET 4.5. To handle enums with Code-First currently you'll do

using enum says invalid conversion from &#039;int&#039; to &#039;type&#039;

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my class I defined an enum like this: class myClass { public: enum access { forL, forM, forA }; typedef access AccessType; AccessType aType; }; Later in defined an object like this: myClass ob; ob->aType = 0; However I get this error: error: invalid conversion from 'int' to 'myClass::AccessType {aka myClass::access}' [-fpermissive] Don't enum fields map to integers? 回答1: No, they are stored as integers but they are distinct types (e.g. you can even overload based on the enum type). You must convert explicitly: myClass ob; ob->aType =