将VB转换为C# [英] Convert VB to C#

查看:112
本文介绍了将VB转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我尝试了至少3个应用程序来转换代码,但它们都不起作用!

VB代码:
对于每个queryObj,作为searcher.Get()中的管理对象. ("VendorSpecific")
MsgBox("Temperature ="& arrVendorSpecific(101))

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!

推荐答案

{
Byte [] arrVendorSpecific =(byte [ ])(queryObj ["VendorSpecific"]);

foreach (ManagementObject queryObj in searcher.Get())
{
Byte[] arrVendorSpecific = (byte[])(queryObj["VendorSpecific"]);
Console.WriteLine("Temperature = " + arrVendorSpecific[101]);
}

此致,
费南多


这篇关于将VB转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆