我有这个枚举:
public enum SalaryAgreements
{
[EnumStringValue("ללא")]
Non,
[EnumStringValue("הסכם 3")]
Agree3,
[EnumStringValue("הסכם 5")]
Agree5,
}
我需要获得“EnumStringValue”。我怎样才能做到这一点?
我尝试toString()
和:
SalaryAgreements agreement;
if ((guider.SalaryAgree != null) || (guider.SalaryAgree == 0))
{
agreement = (guider.SalaryAgree == 1 ? SalaryAgreements.Agree3 : SalaryAgreements.Agree5);
}
else
{
agreement = SalaryAgreements.Non;
}
this.salaryAgree = Enum.GetName(agreement.GetType(), agreement);
但我只得到Non
,Agree3
,Agree5
。我需要ללא
和הסכם
等值。
这类似于Getting attributes of Enum's value,但他们正在使用说明,我需要EnumStringValue
。我无法让他们的例子起作用。