|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
system.enum.getvalueswonder if this something I just don't understand, or is this just wrong. The documentation for the GetValues method says "The elements of the array [returned] are sorted by the values of the enumeration constants". Further the docs state that absent any underlying type definition of the enumeration, the type is assumed to be int32 (a signed integer). Consider the following code: Public Enum MyEnum Entry1 Entry2 Entry3 End Enum Sub DisplayValues For Each i As Integer In System.Enum.GetValues(GetType(MyEnum)) Debug.WriteLine(i.ToString) Next End Sub As expected, the values displayed are 0, 1, and 2. If I redefine the enumeration as: Public Enum MyEnum Entry1 = -1 Entry2 = 0 Entry3 = 1 End Enum Then the values displayed are 0, 1, -1 (!) It seems the values are sorted as *unsigned* integers. Thus: Public Enum MyEnum Entry1 = -1 Entry2 = -2 Entry3 = 0 End Enum displays 0, -2, -1 (!!) What's going on here? I've verified the same behavior occurs in both .NET 1.1 and 2.0. -- Jeff In article <4s8qj2divqifo5av7qs0klq8dubcq52***@4ax.com>,
je.ma***@comcast.net says... > What's going on here? Yeah -- that does look odd and doesn't match the docs. But are you > > I've verified the same behavior occurs in both .NET 1.1 and 2.0. relying on this behavior for something? I guess I don't see it as a big deal (it's a bit of a performance hit anyway since it uses reflection to get the values from the Enum).
How to receive an array of doubles using VB from a C DLL
Question about rounding the decimal Calculate height in millimeters of a font Need help re: vb.net windows forms Controlling how Excel starts when using VB.Net Automation Remoting Having problems with SetWindowText api DataView Question Parsing text files Ctype Datasource to DataTable .. always empty? |
|||||||||||||||||||||||