Why does the following throws the compile error [] cannot be applied to object. (rough translation from german)?
Hashtable entrys = new Hashtable();
string keyPath = "HKEY_CURRENT_USER\\Software\\Test";
string entryName = "testName";
entrys.Add(entryName, new object[]{256, RegistryValueKind.DWord}); // seems to work
foreach(DictionaryEntry entry in entrys)
{
Registry.SetValue(keyPath,
(string)entry.Key,
entry.Value[0], // error here
entry.Value[1]); // and here
}
I expected entry.Value to be an array of objects but apparently the compiler thinks it's just an object. What is wrong here?
Dictionary<string, object[]>instead ofHashtable. Hashtable isn't strongly typed