I have 46 rows of information, 2 columns each row ("Code Number", "Description"). These codes are returned to the client dependent upon the success or failure of their initial submission request. I do not want to use a database file (csv, sqlite, etc) for the storage/access. The closest type that I can think of for how I want these codes to be shown to the client is the exception class. Correct me if I'm wrong, but from what I can tell enums do not allow strings, though this sort of structure seemed the better option initially based on how it works (e.g. 100 = "missing name in request").
Thinking about it, creating a class might be the best modus operandi. However I would appreciate more experienced advice or direction and input from those who might have been in a similar situation.
Currently this is what I have:
class ReturnCode
{
private int _code;
private string _message;
public ReturnCode(int code)
{
Code = code;
}
public int Code
{
get
{
return _code;
}
set
{
_code = value;
_message = RetrieveMessage(value);
}
}
public string Message { get { return _message; } }
private string RetrieveMessage(int value)
{
string message;
switch (value)
{
case 100:
message = "Request completed successfuly";
break;
case 201:
message = "Missing name in request.";
break;
default:
message = "Unexpected failure, please email for support";
break;
}
return message;
}
}