Enum values to string rather than...

  • Thread starter Thread starter Guest
  • Start date Start date
This should get you what you want.

string enumStringValue = ((int)VariablePositionEnum.Row).ToString();

Have A Better One!

John M Deal, MCP
Necessity Software
 
Hello Newsgroup,

I have an enum as such,

public enum VariablePositionEnum
{
Row = 1,
Column = 2,
RowAndColumn = 3,
}

I need (for all intensive purposes) for a control these enumeration values
as strings rather than the enum value name, i.e.
If I want the Row value as a string I need "1" not "Row". I've tried;

VariablePositionEnum.Row.ToString(); yields "Row" - Don't want this, I need
"1".
(string) VariablePositionEnum.Row; - Can't do this.
(string) (int) VariablePositionEnum.Row; - Can't do this either.

Can anyone give me a way to do so, and I hope and am sorry if this is
obviously hitting me in the face...

Many thanks and kind regards,
SpotNet.
 
fishbone, Jay and John,

Thanks guys, three solutions all three worked, thanks again.

Regards,
SpotNet.

:
: Hello Newsgroup,
:
: I have an enum as such,
:
: public enum VariablePositionEnum
: {
: Row = 1,
: Column = 2,
: RowAndColumn = 3,
: }
:
: I need (for all intensive purposes) for a control these enumeration values
: as strings rather than the enum value name, i.e.
: If I want the Row value as a string I need "1" not "Row". I've tried;
:
: VariablePositionEnum.Row.ToString(); yields "Row" - Don't want this, I
need
: "1".
: (string) VariablePositionEnum.Row; - Can't do this.
: (string) (int) VariablePositionEnum.Row; - Can't do this either.
:
: Can anyone give me a way to do so, and I hope and am sorry if this is
: obviously hitting me in the face...
:
: Many thanks and kind regards,
: SpotNet.
:
:
:
:
:
 

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

Similar Threads

Enum Extentions 7
Enum TypeConverter 3
about enum 3
Merge Info From Two Enums 1
Enums & Constructors? 4
Deserialization of invalid enum values 3
enum string value 3
Nullable Enum 2

Back
Top