I have an enum:
public enum baseKey : uint { HKEY_CLASSES_ROOT = 0x80000000, HKEY_CURRENT_USER = 0x80000001, HKEY_LOCAL_MACHINE = 0x80000002,
With some error handling...
uint key = 0; string s = "HKEY_LOCAL_MACHINE"; try { key = (uint)Enum.Parse(typeof(baseKey), s); } catch(ArgumentException) { //unknown string or s is null }