VS: Retrieving value of Enum
It's obvious you want to use Enums instead of numeric or even string values. But you still want to be as flexible as using a numeric or string value.
public enum enJudgement
{
Bad= 1,
Average= 2,
Good = 3
}
Retrieving the string value
enJudgement.Bad.ToString();
Retrieving the numeric value
Type tJudgement = typeof(enJudgement);
Enum.Format(tJudgement , Enum.Parse(tJudgement , enJudgement.Bad.ToString()), "d"));
Converting numeric/string value to Enum
(enJudgement)Enum.Parse(typeof(enJudgement), NumericOrStringvalue);
Friday, August 25, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment