简体   繁体   中英

Conversion of php block to vbnet or c#

I have this block of php that i want to convert to c# or vbnet. I am stuck on the array methods since there is no direct equal to the is array and other bits like array merge. I know that arrays behave differently in php than in c# but thats about it. I am looking online but have not found anything yet. Any ideas?

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

c# has the is operator to determine data type at run time. You can use Concat to merge 2 arrays, you can use String.Split to turn a delimited string into an array. If you give more details about your inputs, we could give you more help. But this should get you close.

There is another question for the same topic php to C# converter .

See answers from @Stegi and @Number 9

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM