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.
:
:
:
:
:
 
Back
Top