is there way assign data type enum members; example;
public enum carpartenum { [string] color, [int] speed }
why want this? because way recorded in database, there carproperties table. , there key-value pair in table.
key: color, value: red; key: speed, value: 250
so when read database want cast key carpartenum , value correct data type.
maybe custom attribute this:
public class mytypeattribute : attribute { private readonly type type; public mytypeattribute (type type) { type = type; } public override string tostring() { return type.tostring(); } }
and use this:
public enum carpartenum { [mytype(typeof(string))] color, [mytype(typeof(int))] speed }
but agree oded's answer should use custom class mirrors database.
Comments
Post a Comment