String of enumeration

  • Thread starter Thread starter MAF
  • Start date Start date
M

MAF

How do I return the translation of an enumartion?

public enum PeriodType

{

Year,

CYear,

Season,

Month,

Week,

Hour

}



I want to pass in 0 and get Year back.
 
You want to get the string version "Year", right?

string period = Enum.GetName(
typeof( PeriodType ), (PeriodType) 0 );

-c
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top