By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,459 Members | 1,472 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,459 IT Pros & Developers. It's quick & easy.

Enum: GetNames and GetValues. Difference?

P: n/a
Hi,

I have enum:

public enum StatusEnum
{
Active = 'A',
Nonactive = 'N',
Deleted = 'D'
}

The strange thing is that both Enum.GetNames(typeof(StatusEnum)) and
Enum.GetValues(typeof(StatusEnum)) methods return same thing - names. How do
I get enum values ('A', 'N', 'D')?

TIA
Armin
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Armin,

foreach(int i in Enum.GetValues(typeof(StatusEnum)))
Console.WriteLine(i);

Works just fine.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

"Armin Bajramovic" <ar******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I have enum:

public enum StatusEnum
{
Active = 'A',
Nonactive = 'N',
Deleted = 'D'
}

The strange thing is that both Enum.GetNames(typeof(StatusEnum)) and
Enum.GetValues(typeof(StatusEnum)) methods return same thing - names. How
do
I get enum values ('A', 'N', 'D')?

TIA
Armin

Nov 16 '05 #2

P: n/a
Thx, you're right.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:u8****************@TK2MSFTNGP09.phx.gbl...
Armin,

foreach(int i in Enum.GetValues(typeof(StatusEnum)))
Console.WriteLine(i);

Works just fine.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

"Armin Bajramovic" <ar******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I have enum:

public enum StatusEnum
{
Active = 'A',
Nonactive = 'N',
Deleted = 'D'
}

The strange thing is that both Enum.GetNames(typeof(StatusEnum)) and
Enum.GetValues(typeof(StatusEnum)) methods return same thing - names. How do
I get enum values ('A', 'N', 'D')?

TIA
Armin


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.