简体   繁体   English

如何将“设置”从Vb转换为C#

[英]how to convert 'Set' from Vb to C#

How to convert the following VB code to C# code? 如何将以下VB代码转换为C#代码?

Set atDIOAOIPIsReady = _
atDIOGObjRepos.InsertOutputObjectIfNew(sIPIsReadyID, atDIOAOIPIsReady)

My idea is : 我的想法是:

atDIOAOIPIsReady -= atDIOGObjRepos.InsertOutputObjectIfNew(ref sIPIsReadyID,atDIOAOIPIsReady);

But it showed me the error as following: 但是它向我显示了以下错误:

  1. The best overload method match for 最佳的重载方法匹配

     ActivVTools._AVTDIOFObjectRepository.InsetOutputObjectIfNew(ref string, ref ActivVTools._IAVTDIOObject) 

    has some invalid arguments. 有一些无效的参数。

  2. Argument '1' must be passed with the 'ref' keyword 参数“ 1”必须与“ ref”关键字一起传递

  3. Argument '2' cannot convert from ActivVTools.AVTDIOActionObjectClass to ref ActivVTools._IAVTDIOObject 参数'2'无法从ActivVTools.AVTDIOActionObjectClass转换为ref ActivVTools._IAVTDIOObject

Based on the documentation (pdf) you need to first create an AVTDIOActionObjectClass object. 根据文档 (pdf),您首先需要创建一个AVTDIOActionObjectClass对象。 In the sample they showed, they set the Description property which will not be necessary. 在他们显示的示例中,他们设置了Description属性,这不是必需的。

The SET keyword is VB6 and has been used to assign references to a variable. SET关键字是VB6,已用于为变量分配引用。 Nowadays with VB.NET this isn`t used/needed anymore. 如今,在VB.NET中已不再使用/需要此功能。

The C# code would be (see the ref keyword for the second parameter): C#代码为(请参阅ref关键字以获取第二个参数):

AVTDIOActionObjectClass atDIOAOIPIsReady=new AVTDIOActionObjectClass ();
atDIOAOIPIsReady= atDIOGObjRepos.InsertOutputObjectIfNew(ref sIPIsReadyID, 
                  ref atDIOAOIPIsReady);

尝试这个:

atDIOAOIPIsReady = atDIOGObjRepos.InsertOutputObjectIfNew(ref sIPIsReadyID, atDIOAOIPIsReady);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM