ASP.NET Hosting

Associating string values to items in code

In a comment to my previous post about advanced enums, Chris Martin provided code for a custom attribute as a solution.

In fact I use something similar to associate string values to class or class members. See my StringValueAttribute class.
This works the same as Chris' implementation, and allows things like:

enum Colors



Color color = Colors.Red;

Too bad we can associate only scalar types, as strings or integers, and not objects...

No Comments