look up constants based on value.
- by PLangeberg
I have a 3rd party struct that is comprised of the following:
[StructLayout(LayoutKind.Sequential, Size=1)]
public struct BigBlueReasonCodes
{
public const int ABC_REASONCODE_DESCRIPTION01 = 1000;
public const int ABC_REASONCODE_DESCRIPTION01 = 1005;
public const int ABC_REASONCODE_DESCRIPTION01 = 1010;
public const int DEF_REASONCODE_DESCRIPTION01 = 2001;
public const int DEF_REASONCODE_DESCRIPTION01 = 2010;
public const int DEF_REASONCODE_DESCRIPTION01 = 2013;
public const int GHI_REASONCODE_DESCRIPTION01 = 3050;
public const int GHI_REASONCODE_DESCRIPTION01 = 3051;
public const int GHI_REASONCODE_DESCRIPTION01 = 3052;
public const string JKL_REASONCODE_DESCRIPTION01 = "XYZ;
public const string GHI_REASONCODE_DESCRIPTION01 = "ST";
static BigblueReasonCodes();
}
I am trying to look up the reason description(the field name) based on the reason code(the value) so my class can do someting like:
string failureReason = GetReasonDescription(reasoncode);
Somethings of mention are some have int values and some have string values.
I am only worried about the ones with int values.
I also only want the ones that start with GHI_ if possible but not a big deal.