1

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;
  }
Ashok Padmanabhan
  • 2,110
  • 1
  • 19
  • 36

2 Answers2

1

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).

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

In general, the scope resolution operator is the dot (.)

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

though, under some cases, the alias resolution operator is similar to that used in PHP or C++ (::), particularly in referencing the global scope.

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

McKay
  • 12,334
  • 7
  • 53
  • 76