2
我试图找出枚举是如何工作的,我试图做一个函数来写入注册表,使用枚举的注册表的根,但也有点糊涂了解枚举
public enum RegistryLocation
{
ClassesRoot = Registry.ClassesRoot,
CurrentUser = Registry.CurrentUser,
LocalMachine = Registry.LocalMachine,
Users = Registry.Users,
CurrentConfig = Registry.CurrentConfig
}
public void RegistryWrite(RegistryLocation location, string path, string keyname, string value)
{
// Here I want to do something like this, so it uses the value from the enum
RegistryKey key;
key = location.CreateSubKey(path);
// so that it basically sets Registry.CurrentConfig for example, or am i doing it wrong
..
}
HMH,我想我明白了,但究竟能在枚举中使用的=因为当时 – user1071461 2012-08-04 03:26:45
你可以用它来非连续,数值分配给枚举。例如,如果你想让枚举从-1开始,然后从那里继续,你可以设置第一个条目= -1。例如:InvalidSelection = -1,NoSelection(值为0),ValidSelection(值为1)。 – 2012-08-04 03:31:23
啊,明白了,谢谢你的信息 – user1071461 2012-08-04 09:54:06