URL: https://www.overclockers.at/coding-stuff/vb-net-parse-to-enum-by-value_246696/page_1 - zur Vollversion wechseln!
ich habe in meinem code z.b. folgendes enum:
Code: VBNETEnum onewire_sensor_family_t DS18S20 = &H10 'sensor is a DS1820 Or DS18S20 DS18B20 = &H28 'sensor is a DS18B20 DS1822 = &H22 'sensor is a DS1822 End Enum
aber parsing by value funktioniert nicht - wenn family 0 ist bekomme ich 0 zurück, bei 1 bekomme ich 1 etc.Code: VBNETDim family as String = "DS18S20" [Enum].TryParse(Of Focuser.onewire_sensor_family_t)(family, returnValue)
ich habe die lösung gefunden - man muss erst mit
checken ob der value im enum enthalten ist.Code: VBNET[Enum].IsDefined
overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2025