hjxlpp
hjxlpp

Reputation: 1

how to convert 'Set' from Vb to C#

How to convert the following VB code to C# code?

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

  3. Argument '2' cannot convert from ActivVTools.AVTDIOActionObjectClass to ref ActivVTools._IAVTDIOObject

Upvotes: 0

Views: 211

Answers (2)

Heslacher
Heslacher

Reputation: 2167

Based on the documentation(pdf) you need to first create an AVTDIOActionObjectClass object. In the sample they showed, they set the Description property which will not be necessary.

The SET keyword is VB6 and has been used to assign references to a variable. Nowadays with VB.NET this isn`t used/needed anymore.

The C# code would be (see the refkeyword for the second parameter):

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

Upvotes: 1

Enigmativity
Enigmativity

Reputation: 117064

Try this:

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

Upvotes: 0

Related Questions