托管 c++ 中的类型转换
您好,在第二行中尝试从对象转换为字符串数组时,它显示编译时错误为
“System::String ^”:本机数组不能包含此托管类型
“初始化”:无法从“System::String ^”转换到'System::String ^[]'
代码:
RegistryKey ^rk = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\Microsoft SQLServer");
String ^instances[] = (String^)rk->GetValue("InstalledInstances");
如何解决这个问题.... 提前致谢。
Hi in the second line while trying to convert from object to String array it shows compile time error as
'System::String ^' : a native array cannot contain this managed type
'initializing' : cannot convert from 'System::String ^' to 'System::String ^[]'
code:
RegistryKey ^rk = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\Microsoft SQLServer");
String ^instances[] = (String^)rk->GetValue("InstalledInstances");
How to fix this ....
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将
instances
声明为数组类型:相反,将其声明为字符串:
You declared
instances
as an array type:Instead, declare it as a string:
将最后一行更改为
(注意没有括号)。 如果密钥包含多字符串,请使用
请参阅RegistryKey.GetValue 文档 了解更多信息。
Change the last line to
(note the absence of brackets). If the key contains a multistring, use
See the documentation for RegistryKey.GetValue for more information.