473,396 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Iterating through a enum

Is this possible?

I have a load of items defined in a enum. I simply want to check if a string
variable if defined in anyone of those enum items. Don't want to have to use
if statement.

Regards
Simon.
Apr 28 '06 #1
2 1525
Simon Hart wrote:
Is this possible?

I have a load of items defined in a enum. I simply want to check if a string
variable if defined in anyone of those enum items. Don't want to have to use
if statement.


Use Enum.IsDefined.

Jon

Apr 28 '06 #2
you can use Enum.GetValues(enumtype)

--
"Simon Hart" <srhartone[no spam]@yahoo.com> schrieb im Newsbeitrag
news:uq****************@TK2MSFTNGP04.phx.gbl...
Is this possible?

I have a load of items defined in a enum. I simply want to check if a
string variable if defined in anyone of those enum items. Don't want to
have to use if statement.

Regards
Simon.

Apr 28 '06 #3

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

Similar topics

4
by: Mattias Brändström | last post by:
Hi! Suppose I want to do some thing like this: enum X { A, B, C, D }; int main() { X a1 = { A, B, C, D }; int size_a = sizeof(a1) / sizeof(X);
8
by: Imran | last post by:
Hello All I have a enum decla like this enum Days // Declare enum type Days { saturday, // saturday = 0 by default sunday = 0, // sunday = 0 as well monday, ...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
1
by: Jamie Winder via .NET 247 | last post by:
Is it possible to iterate through all of the possible values of an enumeration? (with foreach, maybe?) What I need to do is fill a ComboBox with all possible values for an enumeration. e.g ...
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
13
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
1
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
0
by: sven.suursoho | last post by:
Does messing with signal handlers and longjmp affect Python interpreter? I'm trying to find solution for problem, described in...
34
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.