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