1

PHP コードを vbnet に移植しています (vbnet は c# よりも少し得意です)。PHP には、スコープ解決演算子があります。

ここにビットがあります:

$args = phpZenfolio::processArgs( func_get_args() );

c#/vbnet で同等ですか?

関数全体は次のとおりです。これは、vbnet の sub new と同等だと思います。

    public function __construct()
{
    $args = phpZenfolio::processArgs( func_get_args() );
    $this->APIVer = ( array_key_exists( 'APIVer', $args ) ) ? $args['APIVer'] : '1.4';
    // Set the Application Name
    if ( ! isset( $args['AppName'] ) ) {
        throw new PhpZenfolioException( 'Application name missing.', -10001 );
    }
    $this->AppName = $args['AppName'];
    // All calls to the API are done via POST using my own constructed httpRequest class
    $this->req = new httpRequest();
    $this->req->setConfig( array( 'adapter' => $this->adapter, 'follow_redirects' => TRUE, 'max_redirects' => 3, 'ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE, 'connect_timeout' => 5 ) );
    $this->req->setHeader( array( 'User-Agent' => "{$this->AppName} using phpZenfolio/{$this->version}",
                                  'X-Zenfolio-User-Agent' => "{$this->AppName} using phpZenfolio/{$this->version}",
                                  'Content-Type' => 'application/json' ) );
}

プロセス引数ビットは次のとおりです。

private static function processArgs( $arguments )
 {
    $args = array();
    foreach ( $arguments as $arg ) {
        if ( is_array( $arg ) ) {
            $args = array_merge( $args, $arg );
        } else {
            if ( strpos( $arg, '=' ) !== FALSE ) {
                $exp = explode('=', $arg, 2);
                $args[$exp[0]] = $exp[1];
            } else {
                $args[] = $arg;
            }
        }
    }

    return $args;
  }
4

2 に答える 2

1

staticメソッドを呼び出そうとしています:

ClassName.MethodName(args);

メソッドは( Visual Basic では)として明示的に宣言する必要があり、static( SharedVisual Basic では) アクセスできません。thisMe

于 2011-11-22T17:27:08.400 に答える
0

一般に、スコープ解決演算子はドット (.)

http://msdn.microsoft.com/en-us/library/2hxce09y%28v=vs.80%29.aspx

ただし、場合によっては、特にグローバル スコープの参照において、エイリアス解決演算子が PHP や C++ で使用される演算子 (::) に似ています。

http://msdn.microsoft.com/en-us/library/htccxtad.aspx

于 2011-11-22T18:27:18.997 に答える