473,804 Members | 3,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enum: GetNames and GetValues. Difference?

Hi,

I have enum:

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

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

TIA
Armin
Nov 16 '05 #1
2 6260
Armin,

foreach(int i in Enum.GetValues( typeof(StatusEn um)))
Console.WriteLi ne(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******@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

I have enum:

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

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

TIA
Armin

Nov 16 '05 #2
Thx, you're right.

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

foreach(int i in Enum.GetValues( typeof(StatusEn um)))
Console.WriteLi ne(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******@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

I have enum:

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

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

TIA
Armin


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2419
by: Daylor | last post by:
Public Enum COLORS RED= 0 GREEN=1 BLUD =2 ORANGE =4
2
2842
by: smith | last post by:
It's a time saver to "bind" .Net enums to list and comboboxes and all the samples out there seem to use GetNames and GetValues pretty interchangeably. So I was wondering what the logic is to the System.Drawing.RotateFlipType enumeration. GetNames and GetValues results don't seem to synch up and binding to GetValues seems to create duplicates of some elements while"losing" others, and I haven't seen any mention of why that might be.
9
1372
by: thechaosengine | last post by:
Hi all, I have a problem that I havent really come accross before. I need to be able to allow the user to set a dropdown control to a particular colour value. The permissable values come from the Color enumeration and unfortunately I can't change this implementation detail. My question is, how can I load the values into the dropdown using the enumeration, and more importantly, when a user selects an entry in the dropdown, how do
3
16078
by: Richard | last post by:
Okay gang, This should be simple but apparently it's not... I want to use the System.DayOfWeek enum to create and access an array of objects with one object for each day of the week. I'd like the array declaration to be strongly typed to the enum and I'd like to use the enum to access entries in the array. I'd like to write code something like this: #using System;
2
61052
by: Mark | last post by:
Assume you've declared an enum .... public enum MyEnum { First, Second, Third } Without knowing the values of the enum, is it possible to iterate through all the possible values programmatically? Thanks in advance. Mark
3
36310
by: cyshao | last post by:
Hi ,my friends: I have a enum type ,EMyEnum , defigned as . I just want to do something like this: foreach( EMyEnum crrEnum in EMyEnum ) { //do something }
7
9838
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
34
11210
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code snippet that I wrote today that gives me an instant implementation of the pattern. I could easily just always use such an implementation instead of a standard enum, so I wanted to know what you experts all thought. Is there a case for standard enums?
3
5237
by: shapper | last post by:
Hello, I have an enum: Public Enum Color Red Blue Green End Enum
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9588
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.