There is a piece of code, which can be expressed in C #. it is mainly an array problem-php Tutorial

Source: Internet
Author: User
There is a piece of code that you want to use C # to represent. it is mainly an array problem.
$cursor = exequery( TD::conn( ), $query );while ( $rows = mysql_fetch_array( $cursor ) ){$a_bi[$tid]['selected'] = array( );$a_bi[$tid]['unselected'] = array( );}

$cursor = exequery( TD::conn( ), $query );while ( $rows = mysql_fetch_array( $cursor ) ){$tid = $rows['tid'];$rid = $rows['rid'];$report_name = $rows['report_name'];$report_limit_users = $rows['report_limit_users'];$s_type_name = "[".$a_bi[$tid]['name']."]";if ( strpos( $report_limit_users, $s_user ) === FALSE ){$a_report[$rid]['name'] = $s_type_name.$report_name;$a_bi[$tid]['selected'][$rid]['name'] = $s_type_name.$report_name;}else{$a_bi[$tid]['unselected'][$rid]['name'] = $s_type_name.$report_name;}}

It mainly refers to how to use the C # syntax to represent arrays. I have heard that you can use a dictionary, but I still don't know how to write it.


Reply to discussion (solution)

C # does not support multi-dimensional arrays?
Can you replace the key name with a subscript?

How can I write it? here is an example.

For example, $ a_bi [$ tid] ['selected'] [$ rid] ['name']
Writeable
A_bi [tid] [selected] [rid] [name]
Where tid and rid are read variables selected and name are custom variables, values 0, 1, 2, 3, 4 ....

The advantage of this literal translation is that it does not change the form of the original algorithm, and does not need to fully understand the algorithm principle.
The disadvantage is that there is a lot of invalid memory, but it can be optimized based on understanding the algorithm. Of course, that's the end.

In PHP, is this a multi-dimensional array? If you write in C #, it is estimated that an error will be reported. in C #, the ARRAYLIST can be indexed in one dimension. can it be used in multiple dimensions?

Dictionary >
A_bi = new
Dictionary > If it is a dictionary object, is this correct?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.