Forum Discussion

zhe's avatar
zhe
Occasional Contributor
12 years ago
Solved

ref and out parameters in C#


What is the correct way of using a method with ref parameters?



 


Suppose we have a method like this in my assembly:



public static int DoSomething(int Param1, ref MyClass param2)



  • Hi Zhe,


     


    I suppose you are using JScript in your test, right? It has a restriction - JScript doesn't support methods with out-parameters. You can try using this script extension to overcome the issue, or use another scripting language (VBScript or DelphiScript).


     

5 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Zhe,


     


    I suppose you are using JScript in your test, right? It has a restriction - JScript doesn't support methods with out-parameters. You can try using this script extension to overcome the issue, or use another scripting language (VBScript or DelphiScript).


     

  • zhe's avatar
    zhe
    Occasional Contributor
    Hi Tanya!



    Thanks!!



    I couldn't find ConvertJScriptArray() and OutParameterWrapper() in TC 8, are they new functions in TC 9?





    Regards,

    Zhe
  • zhe's avatar
    zhe
    Occasional Contributor
    Hi!



    I followed Tanya's instruction but then got an error like this:



    Type mismatch 'obj.DoSomething'



    Microsoft VBScript runtime error



    out_param_wrapper.vbs Line:1 Column:0




    Could you tell me where you think the problem is? Thanks a lot!!



    Regards,

    Zhe