471,338 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Enum GetValues/GetNames .. is this odd?

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.

To see it just drop a couple of tall listboxes on a form and in the load
add:

ListBox1.DataSource = System.Enum.GetNames(GetType(RotateFlipType))
ListBox2.DataSource = System.Enum.GetValues(GetType(RotateFlipType))

Or dump the same to Output:

Dim arValues as String() = System.Enum.GetValues(GetType(RotateFlipType))
Dim arValues As RotateFlipType() =
System.Enum.GetValues(GetType(RotateFlipType))

For i As Integer = 0 To arNames.Length - 1
Debug.WriteLine(arNames(i) & vbTab & arValues(i).ToString)
Next

yields:

Rotate180FlipXY RotateNoneFlipNone
RotateNoneFlipNone RotateNoneFlipNone
Rotate90FlipNone Rotate270FlipXY
Rotate270FlipXY Rotate270FlipXY
Rotate180FlipNone RotateNoneFlipXY
RotateNoneFlipXY RotateNoneFlipXY
Rotate270FlipNone Rotate90FlipXY
Rotate90FlipXY Rotate90FlipXY
RotateNoneFlipX Rotate180FlipY
Rotate180FlipY Rotate180FlipY
Rotate90FlipX Rotate270FlipY
Rotate270FlipY Rotate270FlipY
Rotate180FlipX RotateNoneFlipY
RotateNoneFlipY RotateNoneFlipY
Rotate270FlipX Rotate270FlipX
Rotate90FlipY Rotate270FlipX

it's not that there's no one to one relation, but that GetValues returns the
odd duplcate text values. Is it just something about this particular enum
or is this logical and do others that I've not seen yet also do this?

Just wonderin'

smith
kirkland, wa
www.smithvoice.com
Jul 21 '05 #1
2 2688
Ahem, bad paste. Those arrays are of course:

Dim arNames As String() = _
System.Enum.GetNames(GetType(RotateFlipType))

Dim arValues As RotateFlipType() = _
System.Enum.GetValues(GetType(RotateFlipType))

....
For i As Integer = 0 To arNames.Length - 1
Debug.WriteLine(arNames(i) & vbTab & arValues(i).ToString)
Next

yields:

Rotate180FlipXY RotateNoneFlipNone
RotateNoneFlipNone RotateNoneFlipNone
Rotate90FlipNone Rotate270FlipXY
Rotate270FlipXY Rotate270FlipXY
Rotate180FlipNone RotateNoneFlipXY
RotateNoneFlipXY RotateNoneFlipXY
Rotate270FlipNone Rotate90FlipXY
Rotate90FlipXY Rotate90FlipXY
RotateNoneFlipX Rotate180FlipY
Rotate180FlipY Rotate180FlipY
Rotate90FlipX Rotate270FlipY
Rotate270FlipY Rotate270FlipY
Rotate180FlipX RotateNoneFlipY
RotateNoneFlipY RotateNoneFlipY
Rotate270FlipX Rotate270FlipX
Rotate90FlipY Rotate270FlipX

it's not that there's no one to one relation, but that GetValues returns
the odd duplcate text values. Is it just something about this particular
enum or is this logical and do others that I've not seen yet also do this?

Just wonderin'

smith
kirkland, wa
www.smithvoice.com

Jul 21 '05 #2
Oy. I just didn't wrap my head fully around the degrees and flippage:
http://thedotnet.com/howto/work148254.aspx

Why do we always figure things out just two tries after we've publicly said
that we couldn't do it? And why is it a sliding scale so that you have to
admit it first and only then do the extra tries work?

The rules of this universe were created by a trickster.

smith

"smith" <rc********@smithvoiceTAKEOUT.com> wrote in message
news:y1*****************@newsread1.news.pas.earthl ink.net...
Ahem, bad paste. Those arrays are of course:

Dim arNames As String() = _
System.Enum.GetNames(GetType(RotateFlipType))

Dim arValues As RotateFlipType() = _
System.Enum.GetValues(GetType(RotateFlipType))

...
For i As Integer = 0 To arNames.Length - 1
Debug.WriteLine(arNames(i) & vbTab & arValues(i).ToString)
Next

yields:

Rotate180FlipXY RotateNoneFlipNone
RotateNoneFlipNone RotateNoneFlipNone
Rotate90FlipNone Rotate270FlipXY
Rotate270FlipXY Rotate270FlipXY
Rotate180FlipNone RotateNoneFlipXY
RotateNoneFlipXY RotateNoneFlipXY
Rotate270FlipNone Rotate90FlipXY
Rotate90FlipXY Rotate90FlipXY
RotateNoneFlipX Rotate180FlipY
Rotate180FlipY Rotate180FlipY
Rotate90FlipX Rotate270FlipY
Rotate270FlipY Rotate270FlipY
Rotate180FlipX RotateNoneFlipY
RotateNoneFlipY RotateNoneFlipY
Rotate270FlipX Rotate270FlipX
Rotate90FlipY Rotate270FlipX

it's not that there's no one to one relation, but that GetValues returns
the odd duplcate text values. Is it just something about this particular
enum or is this logical and do others that I've not seen yet also do
this?

Just wonderin'

smith
kirkland, wa
www.smithvoice.com


Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by thechaosengine | last post: by
3 posts views Thread by Richard | last post: by
2 posts views Thread by Armin Bajramovic | last post: by
3 posts views Thread by cyshao | last post: by
7 posts views Thread by Harris | last post: by
34 posts views Thread by Steven Nagy | last post: by
3 posts views Thread by shapper | last post: by
reply views Thread by rosydwin | last post: by

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.