I am trying to set the array keys as a strings like in the example below, but inC#.
<?php
$array = array();
$array['key_name'] = "value1";
?>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The closest you get in C# is
Dictionary<TKey, TValue>:Note that a
Dictionary<TKey, TValue>is not the same as PHP’s associative array, because it is only accessible by one type of key (TKey— which isstringin the above example), as opposed to a combination of string/integer keys (thanks to Pavel for clarifying this point).That said, I’ve never heard a .NET developer complain about that.
In response to your comment: