I want to check in Enum that passed code exists in any of enum or not. Problem is my enum defined is like below with using code attribute.
public enum TestEnum
{
None,
[Code("FMNG")]
FunctionsManagement,
[Code("INST_MAST_MGT")]
MasterInstManagement
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public class CodeAttribute : Attribute
{
readonly string _code;
public string Code
{
get
{
return _code;
}
}
public CodeAttribute(string code)
{
_code = code;
}
}
Now, I have string available (e.g. "FMNG") and I want to search that enum back that enum exists with passed string which will be in enum attribute.
How can I check/get that enum using or passing string? I tried with using Enum.IsDefined(typeof(ActivityEnum), "FMNG")
but it is not working with attributes of enum.