S
SamIAm
Hi There
I need to record various error codes in my application. These error codes
are from a 3rd party product that I get return codes from when I call their
methods. They are stored as string values i.e. "EQ832" =
"InvalidCodeEntered".
I need to take action based on the return codes like:
string returnCode = SomeFunction(value1, value2);
switch (returnCode){
case "EQ832":
// Take Action
break;
case "EQ833":
// Take Action
break;
}
I would like to have a way of giving the error codes a more meaningfull name
to use in my application. So I can do something like:
string returnCode = SomeFunction(value1, value2);
switch (returnCode){
case ReturnCodes.InvalidCodeEntered:
// Take Action
break;
case ReturnCodes.InvalidMerchantNumber:
// Take Action
break;
}
I cannot use enumerated types as they can only represent integer values. So
I created a class similar to:
public sealed class ReturnCodes
{
private ReturnCodes()
{}
public static string InvalidCodeEntered = "QE832";
public static string InvalidMerchantNumber= "QE833";
}
I can then access the class in my application by using:
ReturnCodes.InvalidCodeEntered
Is there a better way of doing this?
Thanks,
S
I need to record various error codes in my application. These error codes
are from a 3rd party product that I get return codes from when I call their
methods. They are stored as string values i.e. "EQ832" =
"InvalidCodeEntered".
I need to take action based on the return codes like:
string returnCode = SomeFunction(value1, value2);
switch (returnCode){
case "EQ832":
// Take Action
break;
case "EQ833":
// Take Action
break;
}
I would like to have a way of giving the error codes a more meaningfull name
to use in my application. So I can do something like:
string returnCode = SomeFunction(value1, value2);
switch (returnCode){
case ReturnCodes.InvalidCodeEntered:
// Take Action
break;
case ReturnCodes.InvalidMerchantNumber:
// Take Action
break;
}
I cannot use enumerated types as they can only represent integer values. So
I created a class similar to:
public sealed class ReturnCodes
{
private ReturnCodes()
{}
public static string InvalidCodeEntered = "QE832";
public static string InvalidMerchantNumber= "QE833";
}
I can then access the class in my application by using:
ReturnCodes.InvalidCodeEntered
Is there a better way of doing this?
Thanks,
S