它没有抱怨 : 公共类示例 { public enum VehicleType {Car,Truck,Motorbike}; static VehicleType MyVehicleType = VehicleType.Car; } 但是我不要认为它读得不错 比尔 解决方案 >在命名枚举时使用什么约定?使用枚举的变量? 这是一个开始: http://msdn.microsoft.com/library/de...guidelines.asp 此外,请查看: http://msdn.microsoft.com/library/de...Guidelines.asp HTH Erick Sgarbi www.blog .csharpbox.com 您好吗 在命名枚举时使用什么约定和使用枚举的变量? 我喜欢复数/单数,例如: 公共类示例 {公共枚举VehicleTypes {汽车,卡车,摩托车}; 静态车辆类型车辆Type = VehicleTypes.Car; } 但CodeAnalysis / FXCop抱怨它: CA1717:Microsoft.Naming:如果名称''VehicleTypes''是复数, 它不会抱怨 : 公共类示例 {公开enum VehicleType {Car,Truck,Motorbike}; static VehicleType MyVehicleType = VehicleType.Car; } 但我不认为它读得很好 Bill 或******* @ yahoo.com.au 写道: CA1717:Microsoft.Naming:如果名称''VehicleTypes''是复数,将其更改为单数表格 它没有抱怨 : 公共类示例 { public enum VehicleType {Car,Truck,摩托车}; 静态VehicleType MyVehicleType = VehicleType.Car; } 显示投诉的原因是因为复数枚举类型名称 应该与具有FlagsAttribute的枚举一起使用。 考虑这两个: enum VehicleType { 汽车,卡车,摩托车 } [标志] enum JobFunctions { 看门人,老师,HeadOfSchool } 现在在一个人的类中,你可能有: class Person { VehicleType vehicleType; JobFunctions jobFunctions; } 使用这个命名约定,您可以从 人的类型名称中看到只有一种指定的车型,但是有可能 有多种工作职能。 Oliver Sturm - omnibus ex nihibo ducendis sufficit unum 插入空格以防止谷歌电子邮件销毁: MSN oliver @ sturmnet.org Jabber sturm @ ame ssage.de ICQ 27142619 http://www.sturmnet.org / blog 感谢Erick&奥利弗 比尔 Hi ThereWhat convention do you use when naming an enumeration and variablesthat use the enumeration?I like plural/singular, for example:public class Example{public enum VehicleTypes { Car, Truck, Motorbike };static VehicleTypes VehicleType = VehicleTypes.Car;}But CodeAnalysis/FXCop complains about it:CA1717 : Microsoft.Naming : If the name ''VehicleTypes'' is plural,change it to its singular formIt does not complain about:public class Example{public enum VehicleType { Car, Truck, Motorbike };static VehicleType MyVehicleType = VehicleType.Car;}But I don''t think it reads wellBill 解决方案 > What convention do you use when naming an enumeration and variables that use the enumeration?Here is a start: http://msdn.microsoft.com/library/de...guidelines.aspFurthermore, have a look at : http://msdn.microsoft.com/library/de...Guidelines.aspHTHErick Sgarbi www.blog.csharpbox.com Hi There What convention do you use when naming an enumeration and variables that use the enumeration? I like plural/singular, for example: public class Example { public enum VehicleTypes { Car, Truck, Motorbike }; static VehicleTypes VehicleType = VehicleTypes.Car; } But CodeAnalysis/FXCop complains about it: CA1717 : Microsoft.Naming : If the name ''VehicleTypes'' is plural, change it to its singular form It does not complain about: public class Example { public enum VehicleType { Car, Truck, Motorbike }; static VehicleType MyVehicleType = VehicleType.Car; } But I don''t think it reads well Billor*******@yahoo.com.au wrote: CA1717 : Microsoft.Naming : If the name ''VehicleTypes'' is plural, change it to its singular form It does not complain about: public class Example { public enum VehicleType { Car, Truck, Motorbike }; static VehicleType MyVehicleType = VehicleType.Car; }The reason why the complaint is shown is because plural enum type namesare supposed to be used with enums that have the FlagsAttribute.Consider these two:enum VehicleType {Car, Truck, Motorbike}[Flags]enum JobFunctions {Janitor, Teacher, HeadOfSchool}Now in a class of a Person, you might have:class Person {VehicleType vehicleType;JobFunctions jobFunctions;}With this naming convention you can see from the type names that theperson will have just one assigned vehicle type, but it''s possible tohave multiple job functions.Oliver Sturm--omnibus ex nihilo ducendis sufficit unumSpaces inserted to prevent google email destruction:MSN oliver @ sturmnet.org Jabber sturm @ amessage.deICQ 27142619 http://www.sturmnet.org/blogThanks Erick & OliverBill 这篇关于枚举的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-30 03:28