Q:

Help me convert this 2d array code from PHP to C#

Please help me re-write this code sample in PHP to C#:
$stringArray = array();
$stringArray['field1'] = 'value1';
$stringArray['field2'] = 'value2';
$stringArray['field3'] = 'value3';

foreach ($stringArray as $key => $value)
{
    echo $key . ': ' . $value;
    echo "\r\n";
}

A:

Named arrays do not exist in C#. An alternative is to use a Dictionary<string, string> to recreate a similar structure.
Dictionary<string, string> stringArray = new Dictionary<string, string>();
stringArray.Add("field1", "value1");
stringArray.Add("field2", "value2");
stringArray.Add("field3", "value3");

In order to iterate through them, you can use the following:
foreach( KeyValuePair<string, string> kvp in stringArray ) {
    Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}

