我發現了以下代碼,它從註冊表讀取和寫入。讀取註冊表項並在文本框中寫入值
// Write a value to the registry
Microsoft.Win32.RegistryKey key;
key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Names");
key.SetValue("Name","Isabella");
// Get value from registry
key.GetValue("Name");
textBox1.Text = key.GetValue("Name"); // error, how can I do?
key.Close();
如何顯示文本框中的值?
什麼是錯誤? –
不能將類型'object'隱式轉換爲'string'。有一個明確的轉換。可能丟失cast –
string value = key.GetValue(「Name」)。ToString(); [MSDN](http://msdn.microsoft.com/en-us/library/fdf576x1.aspx) – Mike