Search code examples
c#phpvb.netcode-conversion

C# or VBNET equivalent to scope resolution operator?


I am porting php code to vbnet (i'm a little better at vbnet than c#). In the php is the scope resolution operator.

Here's the bit:

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

Equivalent in c#/vbnet?

The whole function is the following which i gues is equivalent to the sub new in vbnet.

    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' ) );
}

Here is the process args bit:

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;
  }

Solution

  • You're trying to call a static method:

    ClassName.MethodName(args);
    

    The method must be explicitly declared as static (Shared in Visual Basic) and cannot access this (Me in Visual Basic).