enum Color {
Red, // Assigned a value of 0
Green, // Assigned a value of 1
Blue, // Assigned a value of 2
Orange // Assigned a value of 3
}
When an enumerated type is compiled, the compiler automatically turns each symbol into a constant field of the type. For example, the compiler treats the Color enumeration shown previously as if you had written code similar to this:
struct Color : System.Enum {
public const Color Red = (Color) 0;
public const Color Green = (Color) 1;
public const Color Blue = (Color) 2;
public const Color Orange = (Color) 3;
}
看了这个我想我们该明白为啥不能在enum重载ToString了吧
是的,通常情况下默认实现是够用了,但是我希望重载 ToString,或许重载不是个好主意
Best Regards,
Yaping
From: shenghe cao [mailto:caoshenghe@gmail.com]
Sent: 2008年11月25日 16:53
To: ZHANG,YA-PING (A-China,ex1)
Cc: objectsolution@googlegroups.com; zyap.cn.dongning@blogger.com
Subject: Re: Recall: enum 中如何处理 ToString()
我今天刚好试验了一下enum
如果将一个enum得collection加到combobox中
显示的就是enum得显示值啊
难道你的需求是需要对ToString做什么处理?我觉得他的默认实现很多时候就够用阿
2008/10/24 <ya-ping_zhang@agilent.com>
ZHANG,YA-PING (A-China,ex1) would like to recall the message, "enum 中如何处理 ToString()".
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "ObjectSolution" group.
To post to this group, send email to objectsolution@googlegroups.com
To unsubscribe from this group, send email to objectsolution+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/objectsolution?hl=en
-~----------~----~----~----~------~----~------~--~---
没有评论:
发表评论