c# - Class design: Access two keys as properties using a constant? -
c# - Class design: Access two keys as properties using a constant? -
now:
2 classes each same constant name, e.g. err123
class1 got public const int err123 = 123;
class2 got public const string err123 = "error 123, went wrong.";
so phone call
int code = class1.err123; string message = class2.err123;
i don't approach because need re-create constant names , touch 2 files when add/change something.
i'd access that:
int code = errors.subcategory1.err123.code; string message = errors.subcategory1.err123.message;
and declaration shouldn't inconvenient. possible? maybe using reflection-magic?
to descript message codes descriptions can utilize enum descrition attribute. get enum description attribute
c# reflection .net-3.5 class-design
Comments
Post a Comment