473,387 Members | 1,379 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,387 software developers and data experts.

what type would this array be?

I think I might create an enumeration with the values Off, Red, Yellow,
Blue, and Overloaded and I might use this for bitwise comparison.

So, when initializing the arrays, if I wanted to load the values "Off"
or "Red" into my arrays instead of "0" and "1", would this still be a
string array? Or would it be an array of the type of my enum? I would be
reading strings from the text file, I guess, but I wasn't sure if this
would be interpreted as enum values (Off and Red), or if another step
was necessary to convert them. If so, then I could just convert my
arrays of 0s and 1s into Offs and Reds, but I don't know how. A foreach
loop, maybe?
Nov 17 '05 #1
3 1391
>Or would it be an array of the type of my enum?
It depends on how you declare you array.
If you declare it as: YourEnumType[] theArray, then yes.
I would be
reading strings from the text file, I guess, but I wasn't sure if this
would be interpreted as enum values (Off and Red), or if another step
was necessary to convert them.

Yes, convertion is necessary. Use Enum.Parse. If you decorated your
enum declaration with FlagsAttribute, that method can even parse
composite value in the form like "Red, Yellow, Blue".

To convert int to enum and vice versa, you only need to cast it.
--
Thi

Nov 17 '05 #2
Truong Hong Thi wrote:
Or would it be an array of the type of my enum?


It depends on how you declare you array.
If you declare it as: YourEnumType[] theArray, then yes.
I would be
reading strings from the text file, I guess, but I wasn't sure if this
would be interpreted as enum values (Off and Red), or if another step
was necessary to convert them.


Yes, convertion is necessary. Use Enum.Parse. If you decorated your
enum declaration with FlagsAttribute, that method can even parse
composite value in the form like "Red, Yellow, Blue".

To convert int to enum and vice versa, you only need to cast it.
--
Thi


What's the difference between [Flags] and [FlagsAttribute]? I've seen
both used in the help files for what seemed like the same thing.
Nov 17 '05 #3
They are just the same thing. The class name in .NET library is
"XXXAttribute". In C#, you can optionally leave the work "Attribute"
out. The C# compiler understands.

Nov 17 '05 #4

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

Similar topics

15
by: M.Siler | last post by:
<HTML> <HEAD> <TITLE></TITLE> <SCRIPT> <!-- var factor_val = new Array(8,7) factor_val = 68.8 factor_val = 55
15
by: damian birchler | last post by:
Hi I'm wondering of what type a structure is. Of course, it is a _structure_, but an array isn't an _array_ either. So of what type is a structure? I'd say a pointer, am I right?
43
by: Mountain Bikn' Guy | last post by:
I have a situation where an app writes data of various types (primitives and objects) into a single dimensional array of objects. (This array eventually becomes a row in a data table, but that's...
8
by: xmail123 | last post by:
Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web methods. ...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
19
by: Fernando Cacciola | last post by:
I'm puzzled, Why and how _exactly_ is this: void Foo<T>(T v ) where T : Interface/Value/Class/class any better than this void Foo( Interface/Value/Class/object v )
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
3
by: chutsu | last post by:
I got errors: qu2-1.c:66: warning: format '%s' expects type 'char *', but argument 2 has type 'char (*)' qu2-1.c:72: warning: format '%s' expects type 'char *', but argument 2 has type 'char (*)'...
9
by: Trent | last post by:
Here is the error while using Visual Studio 2005 Error 1 error LNK2019: unresolved external symbol "void __cdecl print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z) referenced in...
89
by: Tubular Technician | last post by:
Hello, World! Reading this group for some time I came to the conclusion that people here are split into several fractions regarding size_t, including, but not limited to, * size_t is the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.