问题描述
好吧,我尝试了至少3个应用程序来转换代码,但它们都不起作用!
VB代码:
对于每个queryObj,作为searcher.Get()中的管理对象. ("VendorSpecific")
MsgBox("Temperature ="& arrVendorSpecific(101))
C#代码:
foreach(searcher.Get()中的ManagementObject queryObj)
{
Byte [] arrVendorSpecific =(byte [])(queryObj [" VendorSpecific]);
Console.WriteLine(" Temperature ="+ arrVendorSpecific(101));
}
这是我使用C#代码得到的错误:
'arrVendorSpecific'是'variable',但其用法类似于'method',
ps: VB代码可以正常工作!
Well, i have tried at least 3 apps, to convert the code, but neither of them worked!
VB CODE:
For Each queryObj As ManagementObject in searcher.Get()
Dim arrVendorSpecific As Byte() = queryObj("VendorSpecific")
MsgBox("Temperature = " & arrVendorSpecific(101))
C# CODE:
foreach (ManagementObject queryObj in searcher.Get())
{
Byte[] arrVendorSpecific = (byte[])(queryObj["VendorSpecific"]);
Console.WriteLine("Temperature = " + arrVendorSpecific(101));
}
This ir the error i get with the C# code:
'arrVendorSpecific' is a 'variable' but is used like a 'method'
ps: the VB code works fine!
推荐答案
此致,
费南多
这篇关于将VB转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!