A ref or out argument must be an assignable variable

前端 未结 1 1310
暖寄归人
暖寄归人 2020-12-19 08:53

I\'m coding an application which can make a reverse proxy connection but I have a problem! The error is here: new Form1.ProxyConfig()

When I try to run

相关标签:
1条回答
  • 2020-12-19 09:30

    You cannot create a variable and pass it as a reference at the same time like you're doing there. Try this:

    var config = new Form1.ProxyConfig()
    {
        pclient_port = form2.ClientPort,
        pp_start = form2.LocalStartPort,
        pp_end = form2.LocalEndPort
    };
    
    int num1 = Form1.ProxyListenerStart( ref config, ref this._PN );
    

    The reason is that it really wouldn't make any sense, consider the following scenario:

    if( int.TryParse( "123", out new int() ) )
    {
        // there's no way for us to actually use the value TryParse stored
        // into the out parameter, since it doesn't have a name
    }
    
    0 讨论(0)
提交回复
热议问题