Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. A parameter specifies whether the operation is case-sensitive.
[Visual Basic] Overloads Public Shared Function Parse( _ ByVal enumType As Type, _ ByVal value As String, _ ByVal ignoreCase As Boolean _ ) As Object
[C#] public static object Parse( Type enumType, string value, bool ignoreCase );
[JScript] public static function Parse( enumType : Type, value : String, ignoreCase : Boolean ) : Object;
Parameters enumType The Type of the enumeration. value A string containing the name or value to convert. ignoreCase If true, ignore case; otherwise, regard case. Return Value An object of type enumType whose value is represented by value.
duh.. ja... string + int = string... dog ser der ikke så pænt ud, synes jeg... og mon ikke også det er hurtigere at bruge i.ToString(), da du ved at bruge ""+i for oprettet en undødig streng til at indeholde i
Hvis man har en int som er 4 byte 0x00 0x00 0x00 0x03 og skal have det konverteret til en enum med værdi 3 og som også er 4 bytes 0x00 0x00 0x00 0x03, så tror jeg ikke at man vil konvertere til streng og parse den.
En enum er bare en int (eller anden numerisk type) med lidt smarte navne og begrænset range.
Eller for at citere fra sektion 13.2.2 i C# standarden:
13.2.2 Explicit enumeration conversions The explicit enumeration conversions are: • From sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, or decimal to any enum-type. • From any enum-type to sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, or decimal. • From any enum-type to any other enum-type. An explicit enumeration conversion between two types is processed by treating any participating enum-type as the underlying type of that enum-type, and then performing an implicit or explicit numeric conversion between the resulting types. [Example: For example, given an enum-type E with and underlying type of int, a conversion from E to byte is processed as an explicit numeric conversion (§13.2.1) from int to byte, and a conversion from byte to E is processed as an implicit numeric conversion (§13.1.2) from byte to int. end example]
hvorfor poste noget efter 22 maaneder som allerede er skrevet ?
(14/04-2004 13:22:44)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.